I'm experiencing some difficulties using JUnit 4.5 in Eclipse, when I use @Before annotation it just does nothing (I may use setUp() which works of course, but I'm just wondering what is wrong), while it works perfectly in Netbeans.. Any thoughts?
Because I cam here via a Google Search, and had to dig quite a bit deeper to see the actual solution:
As @Pace said in the comments, if you extend TestCase
, Eclipse treats the Test as JUnit Version 3 or older, and does not respect the @Before
annotation - also descripred here: JUnit + Maven + Eclipse: Why @BeforeClass does not work?
Hence, removing the extend TestCase
causes fixes the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With