I have a problem with Idea 14 and JUnit. I can't run @BeforeClass and @AfterClass methods in proper order (before all test and after all test). Every time order is different. I tried to reinstall IDEA, delete all settings but nothing works. Please help. This is example of my test code:
package com.rent.test;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import static org.junit.Assert.*;
import org.junit.Test;
public class testnewTest {
static int num;
static int num1;
@BeforeClass
public static void OnceExecutedBeforeAll() {
System.out.println("@BeforeClass: onceExecutedBeforeAll");
num = 15;
num1 = 16;
}
@AfterClass
public static void after() throws Exception {
System.out.println("End");
}
@Test
public void testLogin() throws Exception {
System.out.println("test");
assertEquals(15, num);
}
@Test
public void testGetOrdersDate() throws Exception {
System.out.println("test2");
assertEquals(16, num1);
}
}
This is output:
test2
@BeforeClass: onceExecutedBeforeAll
test
End