Skip to content

Instantly share code, notes, and snippets.

@maeste
Created October 27, 2009 07:09
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 maeste/219389 to your computer and use it in GitHub Desktop.
Save maeste/219389 to your computer and use it in GitHub Desktop.
public class AnotherClass {
@TestedBy (class="NullVerifier" method="shouldNotreturnNull")
public String anotherMethod(String param);
}
public class ImpleOne implements IunderTest {
public String methodOne() {
//implementation....
}
}
public class ImpleTwo implements IunderTest {
public String methodOne() {
//implementation....
}
}
public interface IunderTest {
@TestedBy (class="TestClass" method="pippo")
@TestedBy (class="NullVerifier" method="shouldNotreturnNull")
public String methodOne();
}
package it.javalinux.testedby.commontests;
import static it.javalinux.testedby.factories.ClassUnderTestInstanceFactory.invokeMethodUnderTest;
public class NullVerifier {
@Test
public void shouldNotreturnNull() {
Object result = invokeMethodUnderTest();
//assertions on result to be not null
}
}
}
import static it.javalinux.testedby.factories.ClassUnderTestInstanceFactory.createInstance;
public class TestClass {
@Test
public void pippo() {
IunderTest ut= createInstance(IunderTest.class);
String result = ut.methodOne();
//assertions on result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment