CVS: junit/src/org/junit/tests MixInTest.java, NONE, 1.1 AllTests.java, 1.3, 1.4 CustomRunnerTest.java, 1.2, NONE
David Saff <[email protected]>
| Newsgroups | gmane.comp.java.junit.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/junit/junit/src/org/junit/tests
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8678/src/org/junit/tests
Modified Files:
AllTests.java
Added Files:
MixInTest.java
Removed Files:
CustomRunnerTest.java
Log Message:
Added ability to "mix in" test elements from another class
--- NEW FILE: MixInTest.java ---
package org.junit.tests;
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.internal.runners.MixIn;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
public class MixInTest {
private static final String GLOBAL_STATE_IS_INVALID= "global state is invalid";
public static class CustomTest {
@Before
public static void assertGlobalStateIsValid(Object test) {
Assert.fail(GLOBAL_STATE_IS_INVALID);
}
}
@MixIn(CustomTest.class)
public static class UsesGlobalState {
@Test
public void foo() {
}
}
@Test
public void failsWithGlobalState() {
Result result= JUnitCore.runClasses(UsesGlobalState.class);
assertEquals(1, result.getFailureCount());
assertEquals(GLOBAL_STATE_IS_INVALID, result.getFailures().get(0)
.getMessage());
}
public static class ExtraTest {
@Test
public static void bar(Object test) {
}
}
@MixIn({CustomTest.class, ExtraTest.class})
public static class Combined {
}
@Test
public void extendWithMultipleClasses() {
Result result= JUnitCore.runClasses(UsesGlobalState.class);
assertEquals(1, result.getFailureCount());
assertEquals(GLOBAL_STATE_IS_INVALID, result.getFailures().get(0)
.getMessage());
}
}
Index: AllTests.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/tests/AllTests.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- AllTests.java 13 Dec 2006 02:10:51 -0000 1.3
+++ AllTests.java 27 Dec 2006 17:45:54 -0000 1.4
@@ -10,7 +10,7 @@
@SuiteClasses({
ListenerTest.class,
FailedConstructionTest.class,
- CustomRunnerTest.class,
+ MixInTest.class,
TestDescriptionTest.class,
SuiteDescriptionTest.class,
AllTestsTest.class,
--- CustomRunnerTest.java DELETED ---
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV