Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse JUnit @Before annotation problem

Tags:

junit

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?

like image 903
Jarek Avatar asked Jun 12 '10 20:06

Jarek


1 Answers

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

like image 113
Blitz Avatar answered Sep 27 '22 19:09

Blitz