Can I use extensions with @BeforeClass/@Afterclass inside Features?

29 views
Skip to first unread message

Alex Philippi

unread,
Mar 21, 2014, 6:50:29 AM3/21/14
to jna...@googlegroups.com
Hi,
I play around with Jnario and I created a feature with two scenarios. I already got a JUnit testclass with @BeforeClass and @AfterClass annotation to start a jetty server. Now I  want to use this junit base class to start the jetty server before the first scenario and stop the jetty server after the last scenario. Therefore I define extension static SeleniumExtension = new SeleniumExtension() between Background and Given block. If I test my feature, the first scenario works fine, but the @AfterClass annotated method (stopJetty) will be executed after the first scenario.

Could someone help me here out? Is this the correct way to use @BeforeClass and @BeforeClass annotated methods inside features?

Thnx
Alex

Sebastian Benz

unread,
Mar 22, 2014, 10:49:28 AM3/22/14
to jna...@googlegroups.com
Hi Alex,

this is currently not supported. The problem is that each scenario is implemented as a separate class and therefore @BeforeClass / @AfterClass does the same as a normal @Before and @After. I have thought about this problem before, but haven't found a simple way to add this feature. Furthermore, in my experience the use cases where you need a Before/After class are not that common. Much more common are cases in which you need to setup something before all the tests are run, which looks like your use case. These can be easily solved in other ways...

Feel free to disagree, ;-)

Sebastian




--
You received this message because you are subscribed to the Google Groups "Jnario" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jnario+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages