Skip to content

Instantly share code, notes, and snippets.

@tuphamphuong
Created January 13, 2016 07:29
Show Gist options
  • Save tuphamphuong/91e967429c730f6dd611 to your computer and use it in GitHub Desktop.
Save tuphamphuong/91e967429c730f6dd611 to your computer and use it in GitHub Desktop.
JUnit Enclosed test
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
/**
* Created by Tu Pham Phuong - phamptu@gmail.com on 1/13/16.
*/
@RunWith(Enclosed.class)
public class EnclosedTest {
abstract public static class SharedSetUp {
@Before
public void printSomething() {
System.out.println("Helllo");
}
}
public static class FirstTest extends SharedSetUp {
@Test
public void assertThatSomethingIsTrue() {
System.out.println("assertThatSomethingIsTrue");
assertEquals(true, true);
}
}
public static class SecondTest extends SharedSetUp {
@Test
public void assertThatSomethingIsFalse() {
System.out.println("assertThatSomethingIsFalse");
assertEquals(false, false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment