Muki-SkyWalker / specs

Automatically exported from code.google.com/p/specs
Other
0 stars 0 forks source link

doAfterSpec executes too early when ran with setSequential #156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the following specification with specs 1.6.5

import org.specs.Specification

object SetSequentialIssue extends Specification {
  doBeforeSpec { doBeforeSpecInvoked = true; println("--doBeforeSpec--") }
  doAfterSpec { doAfterSpecInvoked = true; println("--doAfterSpec--") }

  var doBeforeSpecInvoked = false
  var doAfterSpecInvoked = false

  shareVariables()
  setSequential()

  "System 1" should {
    "execute example 1 after doBeforeSpec and before doAfterSpec" in {
      println("executing example 1")
      doBeforeSpecInvoked must_== true
      doAfterSpecInvoked must_== false
    }
    "execute example 2 after doBeforeSpec and before doAfterSpec" in {
      println("executing example 2")
      doBeforeSpecInvoked must_== true
      doAfterSpecInvoked must_== false
    }
  }
}

What is the expected output? What do you see instead?

Expected output:
--doBeforeSpec--
executing example 1
executing example 2
--doAfterSpec--

Current output:
--doBeforeSpec--
executing example 1
--doAfterSpec--
executing example 2

When commenting out the call to setSequential() everything runs as expected.

What version of the product are you using? On what operating system?

specs 1.6.5-SNAPSHOT (managed dependency in sbt: see below)
scala 2.8.0.final 
java  1.6.0_20
sbt   0.7.4 

Please provide any additional information below.

This issue is maybe related to: 
http://code.google.com/p/specs/issues/detail?id=134

My sbt project configuration:
class project(info: ProjectInfo) extends DefaultProject(info) {
  val specs = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.5-SNAPSHOT"
  val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
}

Original issue reported on code.google.com by daniel.k...@gmail.com on 5 Aug 2010 at 6:49

GoogleCodeExporter commented 9 years ago
Same problem with specs versions:
1.6.5 (as opposed to 1.6.5-SNAPSHOT)
1.6.6-SNAPSHOT

Original comment by daniel.k...@gmail.com on 5 Aug 2010 at 7:22

GoogleCodeExporter commented 9 years ago
Thanks for checking with the latest versions too :-)

I'm going to have a look at that.

Original comment by etorrebo...@gmail.com on 5 Aug 2010 at 7:25

GoogleCodeExporter commented 9 years ago
I have a first fix that should work with sbt (still needs to test that) but it 
doesn't work yet with JUnit as a runner: 
http://nexus.scala-tools.org/content/repositories/snapshots/org/scala-tools/test
ing/specs_2.8.0/1.6.6-SNAPSHOT/

In any case, an easy workaround for your case is to execute the "afterSpec" 
code directly after the last example without using any doAfterSpec (the only 
thing though is that you need to make sure that no exception is thrown in that 
case)

Original comment by etorrebo...@gmail.com on 5 Aug 2010 at 12:32

GoogleCodeExporter commented 9 years ago
I confirm that this fix is working ok with sbt

Original comment by etorrebo...@gmail.com on 5 Aug 2010 at 12:36

GoogleCodeExporter commented 9 years ago
Many thanks for your fast response! I'm trying to validate that it is fixed but 
having trouble getting it to work.
When I try to run it with the following sbt configuration:

import sbt._
class project(info: ProjectInfo) extends DefaultProject(info) {
  val specs = "org.scala-tools.testing" % "specs_2.8.0" % "1.6.6-SNAPSHOT"
  val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"
}

I get this error:
[error] Error running update: sbt.ResolveException: unresolved dependency: 
javax.script#js-engine;1.0: not found
[error] unresolved dependency: javax.script#script-api;1.0: not found
[error] unresolved dependency: javax.script#script-js;1.0: not found

This may be an sbt related problem. If I just download the jar to my lib folder 
and run it within sbt I get:

[info] == test-compile ==
[info]   Source analysis: 0 new/modified, 1 indirectly invalidated, 0 removed.
[info] Compiling test sources...
[error] error while loading SpecFailureException, read error
[error] one error found
[info] == test-compile ==
[error] Error running test-compile: Compilation failed

Do you know what's wrong here? Is this a problem with my sbt config and I'm on 
the wrong list here?

Original comment by daniel.k...@gmail.com on 5 Aug 2010 at 7:19

GoogleCodeExporter commented 9 years ago
I think I need to work on my own sbt project. Those dependencies are not 
mandatory so I need to check on the pom file that sbt is generating. You can 
get them from this repo if that helps:
val specsRepo = Resolver.url("specs-repo", new 
java.net.URL("http://specs.googlecode.com/svn/maven2"))

Then I have no idea about the other error. I'll try to do some testing on this 
during the week-end.

Original comment by etorrebo...@gmail.com on 6 Aug 2010 at 7:38

GoogleCodeExporter commented 9 years ago
I fixed the remaining junit and redeployed using by original maven pom file. 
Please check on your end if it works ok.

Original comment by etorrebo...@gmail.com on 7 Aug 2010 at 12:33

GoogleCodeExporter commented 9 years ago
I confirm that everything is working as expected with the current 
1.6.6-SNAPSHOT.
Also the problem with the missing dependencies is fixed.
Many thanks for your effort. specs is an amazing piece of software!

Original comment by daniel.k...@gmail.com on 7 Aug 2010 at 3:24

GoogleCodeExporter commented 9 years ago

Original comment by etorrebo...@gmail.com on 31 Mar 2011 at 8:05