1 21 package db4ounit.tests; 22 23 import db4ounit.Assert; 24 import db4ounit.CodeBlock; 25 import db4ounit.ReflectionTestSuiteBuilder; 26 import db4ounit.TestCase; 27 28 public class ReflectionTestSuiteBuilderTestCase implements TestCase { 29 30 private final static class ExcludingReflectionTestSuiteBuilder extends 31 ReflectionTestSuiteBuilder { 32 public ExcludingReflectionTestSuiteBuilder(Class [] classes) { 33 super(classes); 34 } 35 36 protected boolean isApplicable(Class clazz) { 37 return clazz!=NotAccepted.class; 38 } 39 } 40 41 public static class NonTestFixture { 42 } 43 44 public void testUnmarkedTestFixture() { 45 46 final ReflectionTestSuiteBuilder builder = new ReflectionTestSuiteBuilder(NonTestFixture.class); 47 48 Assert.expect(IllegalArgumentException .class, new CodeBlock() { 49 public void run() throws Exception { 50 builder.build(); 51 } 52 }); 53 } 54 55 public static class Accepted implements TestCase { 56 public void test() { 57 } 58 } 59 60 public static class NotAccepted implements TestCase { 61 public void test() { 62 } 63 } 64 65 public void testNotAcceptedFixture() { 66 ReflectionTestSuiteBuilder builder = new ExcludingReflectionTestSuiteBuilder(new Class []{Accepted.class,NotAccepted.class}); 67 Assert.areEqual(1,builder.build().getTests().length); 68 } 69 } 70 | Popular Tags |