JUnit + Maven + Eclipse: Why @BeforeClass does not work? -


I am using JUnit 4, Maven 2 and the latest Eclipse. The problem is simple: before executing my tests, I would like to setup some setup (connecting to a database).

I tried the first class at several different places but Eclipse and Maven are ignoring this. Any help in completing this initial setup?

Thank you!

  Expands public abstract class testcases testcases {@BeforeClass Public Static Zero doBeforeClass () Exception {System.out.println ("No Good @ Beaver Class"); // DATABASE SETUP}} Now testing increasing the BaseTestCase:  
  public class LoginActionTest buststyle extension {@Test Public Zero Test Notting} { System .out.println ("test here"); AssertEquals (true, true); }}  

Mayen and Eclipse just ignore my @encleclass ??? To setup any other way before the test?

Sergio, you were right about the extension of the testes that caused the problem. If you expand the testcases, JUnit considers your test class as an old (prejoinit 4 class) and runs org.junit.internal.runners.JUnit38ClassRunner to run it . JUnit38ClassRunner does not know about @BeforeClass annotation. For more information see runnerForClass method AllDefaultPossibilitiesBuilder and runnerForClass method JUnit3Builder .

Note: This problem is not related to Eclipse or Maven.


Comments