Skip to content

Instantly share code, notes, and snippets.

@mulderbaba
Created February 22, 2013 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mulderbaba/5014153 to your computer and use it in GitHub Desktop.
Save mulderbaba/5014153 to your computer and use it in GitHub Desktop.
@before and @after annotations demo with class hierarchy
package org.ankarajug.testinfected.gist;
import org.junit.After;
import org.junit.Before;
/**
* User: mertcaliskan
* Date: 2/22/13
*/
public class ClassA {
@Before
public void classASetup() {
System.out.println("class A setup");
}
@After
public void classATearDown() {
System.out.println("class A tear down");
}
}
package org.ankarajug.testinfected.gist;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* User: mertcaliskan
* Date: 2/22/13
*/
public class ClassB extends ClassA {
@Before
public void classBSetup() {
System.out.println("class B setup");
}
@After
public void classBTearDown() {
System.out.println("class B tear down");
}
@Test
public void doTheTest() {
System.out.println("test test test");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment