{"action":"created","issue":{"url":"https://api.github.com/repos/etorreborre/specs2/issues/446","labels_url":"https://api.github.com/repos/etorreborre/specs2/issues/446/labels{/name}","comments_url":"https://api.github.com/repos/etorreborre/specs2/issues/446/comments","events_url":"https://api.github.com/repos/etorreborre/specs2/issues/446/events","html_url":"https://github.com/etorreborre/specs2/issues/446","id":123501310,"number":446,"title":"Wrong execution order with nested Example","user":{"login":"oswaldo","id":77538,"avatar_url":"https://avatars.githubusercontent.com/u/77538?v=3","gravatar_id":"","url":"https://api.github.com/users/oswaldo","html_url":"https://github.com/oswaldo","followers_url":"https://api.github.com/users/oswaldo/followers","following_url":"https://api.github.com/users/oswaldo/following{/other_user}","gists_url":"https://api.github.com/users/oswaldo/gists{/gist_id}","starred_url":"https://api.github.com/users/oswaldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oswaldo/subscriptions","organizations_url":"https://api.github.com/users/oswaldo/orgs","repos_url":"https://api.github.com/users/oswaldo/repos","events_url":"https://api.github.com/users/oswaldo/events{/privacy}","received_events_url":"https://api.github.com/users/oswaldo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-22T15:28:33Z","updated_at":"2015-12-22T22:30:20Z","closed_at":null,"body":"The following code prints as expected:\r\n\r\n```\r\n@RunWith(classOf[JUnitRunner]) //to be able to run with surefire maven plugin\r\nclass SpecsSampleSpec extends Specification with BeforeAfterAll {\r\n  sequential\r\n\r\n  override def beforeAll = {\r\n    println(\"beforeAll\")\r\n  }\r\n\r\n  override def afterAll = {\r\n    println(\"afterAll\")\r\n  }\r\n\r\n  \"first\" in {\r\n    println(\"first\")\r\n    success\r\n  }\r\n\r\n  \"second\" in {\r\n    println(\"second\")\r\n    true should beTrue\r\n  }\r\n\r\n  \"third\" in {\r\n    println(\"third\")\r\n    ok\r\n  }\r\n\r\n}\r\n```\r\n\r\nPrints:\r\n\r\n>-------------------------------------------------------\r\n> T E S T S\r\n>-------------------------------------------------------\r\n>Running SpecsSampleSpec\r\n>beforeAll\r\n>first\r\n>second\r\n>third\r\n>afterAll\r\n>Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.296 sec\r\n\r\nBut adding a nested Example breaks the order:\r\n\r\n```\r\n@RunWith(classOf[JUnitRunner])\r\nclass SpecsSampleSpec extends Specification with BeforeAfterAll {\r\n  sequential\r\n\r\n  override def beforeAll = {\r\n    println(\"beforeAll\")\r\n  }\r\n\r\n  override def afterAll = {\r\n    println(\"afterAll\")\r\n  }\r\n\r\n  \"first\" in {\r\n    println(\"first\")\r\n    success\r\n\r\n    //this breaks the order\r\n    \"then\" in {\r\n      print(\"then\")\r\n      ok\r\n    }\r\n  }\r\n\r\n  \"second\" in {\r\n    println(\"second\")\r\n    true should beTrue\r\n  }\r\n\r\n  \"third\" in {\r\n    println(\"third\")\r\n    ok\r\n  }\r\n\r\n}\r\n```\r\n\r\nPrints:\r\n\r\n>-------------------------------------------------------\r\n> T E S T S\r\n>-------------------------------------------------------\r\n>first\r\n>Running SpecsSampleSpec\r\n>first\r\n>beforeAll\r\n>thensecond              <-Something was run in parallel?\r\n>third\r\n>afterAll\r\n>Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.295 sec \r\n\r\nUsing Java 8, Specs2 3.6.6, Scala 2.11.7, Maven 3.3.3, Surefire 2.18.1 (aparently it does not work with the latest, 2.19)"},"comment":{"url":"https://api.github.com/repos/etorreborre/specs2/issues/comments/166751622","html_url":"https://github.com/etorreborre/specs2/issues/446#issuecomment-166751622","issue_url":"https://api.github.com/repos/etorreborre/specs2/issues/446","id":166751622,"user":{"login":"etorreborre","id":10988,"avatar_url":"https://avatars.githubusercontent.com/u/10988?v=3","gravatar_id":"","url":"https://api.github.com/users/etorreborre","html_url":"https://github.com/etorreborre","followers_url":"https://api.github.com/users/etorreborre/followers","following_url":"https://api.github.com/users/etorreborre/following{/other_user}","gists_url":"https://api.github.com/users/etorreborre/gists{/gist_id}","starred_url":"https://api.github.com/users/etorreborre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etorreborre/subscriptions","organizations_url":"https://api.github.com/users/etorreborre/orgs","repos_url":"https://api.github.com/users/etorreborre/repos","events_url":"https://api.github.com/users/etorreborre/events{/privacy}","received_events_url":"https://api.github.com/users/etorreborre/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T22:30:19Z","updated_at":"2015-12-22T22:30:19Z","body":"This is not really a bug, but not really a feature either :-(. In specs2 you can nest blocks but you can not have an \"example\" be a part of another \"example\".\r\n\r\nThis means that the code\r\n```\r\nprintln(\"first\")\r\nsuccess\r\n```\r\nis not considered as an example which must be reported as such but just as some code to execute before creating the next block which is the \"then\" example. The correct form is\r\n```\r\n\"first\" in {\r\n   \"do this\" in {\r\n      println(\"first\")\r\n      success\r\n   }\r\n\r\n    //this breaks the order\r\n    \"then\" in {\r\n      print(\"then\")\r\n      ok\r\n    }\r\n  }\r\n```\r\n\r\nNote however that there is a possibility to create a [\"continuation\"](https://etorreborre.github.io/specs2/guide/SPECS2-3.6.6/org.specs2.guide.CreateOnlineSpecifications.html) for a given example. This is interesting because the result of one example may decide on the creation or not of many other ones."}}