My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Troubleshooting  
Pitfalls and errors that you can avoid
Featured
Updated Jun 23, 2010 by etorrebo...@gmail.com

This page lists tips on errors you may encounter while using specs.

NoSuchMethodError

You may have dependencies issues. Please check the version numbers of all the libraries you're using: dependencies

Strange compilation error

The following spec would raise a compilation error:

"My Thing" should {
  "do something" {
     ...possibly long setup...
     something must ... other // matcher
  }

This would generate:

> "message without in" { "value" must beEqual("anotherValue") }
> error: type mismatch;
> found   : org.specs.specification.Result[java.lang.String]
> required: Int
>       "message without in" { "value" must beEqual("anotherValue") }

This is because there is a missing "in" after the example description, so everything inside the accolade is expected to be an Int used to access one character of "do something" (see  issue 22 )

Skipped example

This example would appear as "skipped" in the reports:

  "my example" in {
    doSomething()     // appears as skipped
  }

The example shows as 'skipped' because it is a warning that it is not specifying any expectations. We're taking the view here that expecting a piece of code not to throw an exception is a sign that your example is incomplete as a specification of the intended behavior. However if that's really what you mean, you can declare that by using isExpectation:

  "my example" in {
    doSomething().isExpectation     // appears as passed if no exception is thrown
  }

If you don't like this default behavior you can override it by changing your specs configuration: http://code.google.com/p/specs/wiki/RunningSpecs#Override_specs_default_behavior

The objects to compare have the same toString value

For example you're comparing List("1") to List(1) using must_==. After the fix for  issue 141  you will get a warning saying Values have the same string representation but possibly different types like List[Int] and List[String].

My specification is leaking some resources

This may be a case like  issue 150  where specs is executing examples in isolation by cloning the specification but not always calling doAfter to clean the resources. You can read more here and there.

Comment by jzaugg, May 19, 2009

I was surprised when an example with no expectations was ignored.

"my example" in {
   doSomething()
   // example is ignored! This works, though: doSomething() must be_==(())
}
Comment by project member etorrebo...@gmail.com, Oct 20, 2009

This behavior is indeed the default behavior and is meant at warning you that an example is not specifying any expectations. This can be overriden by changing your specs configuration: http://code.google.com/p/specs/wiki/RunningSpecs#Override_specs_default_behavior

You can also declare any piece of code to be an expectation in itself with:

doSomething.isExpectation

Comment by tarasevi...@gmail.com, Jan 10, 2010

Just adding new error message to make the issue more searchable:

scala> "message without in" { "value" must beEqual("anotherValue") }
<console>:12: error: type mismatch;
 found   : org.specs.specification.Result[java.lang.String]
 required: Int
       "message without in" { "value" must beEqual("anotherValue") }
                                      ^

Sign in to add a comment
Powered by Google Project Hosting