let @Before/@After work for superclasses

This commit is contained in:
Wouter Groeneveld 2011-06-26 21:44:55 +02:00
parent ad2f3595b9
commit e58acab9c8
52 changed files with 50 additions and 39 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
target
eclipsecompiled
.classpath
.project
.settings

0
pom.xml Executable file → Normal file
View File

View File

View File

0
src/main/java/be/cegeka/junit/jasmine/JasmineSpec.java Executable file → Normal file
View File

View File

View File

View File

View File

@ -2,7 +2,6 @@ package be.cegeka.junit.jasmine;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
@ -134,14 +133,10 @@ public class JasmineTestRunner extends Runner {
}
private void fireMethodsWithSpecifiedAnnotationIfAny(Object testClassInstance, Class<? extends Annotation> annotation) {
for (Method method : testClass.getDeclaredMethods()) {
for (Method method : testClass.getMethods()) {
try {
if (method.getAnnotation(annotation) != null) {
if (!Modifier.isPublic(method.getModifiers())) {
throw new IllegalStateException("Annotated method should be public!");
}
method.setAccessible(true);
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes.length == 0) {

View File

0
src/main/java/be/cegeka/rhino/RhinoContext.java Executable file → Normal file
View File

0
src/main/java/be/cegeka/rhino/RhinoRunnable.java Executable file → Normal file
View File

View File

View File

View File

@ -3,9 +3,6 @@ package be.cegeka.junit.jasmine.classes;
import static junit.framework.Assert.fail;
import static org.fest.assertions.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Before;
@ -13,38 +10,27 @@ import be.cegeka.junit.jasmine.JasmineSuite;
import be.cegeka.rhino.RhinoContext;
@JasmineSuite(specs = { "emptySpec.js" })
public class JasmineTestRunnerBeforeAndAfterClass {
public class JasmineTestRunnerBeforeAndAfterClass extends JasmineTestRunnerBeforeAndAfterSuperClass {
private static final int RUN_MIJ_FLAG = 0;
private static final int RUN_MIJ_OOK_FLAG = 1;
@Before
public void runMij() {
assertThat(runs).isEmpty();
runs.add(RUN_MIJ_FLAG);
}
List<Integer> runs = new ArrayList<Integer>();
@After
public void runMijAfter() {
assertThat(runs).containsOnly(RUN_MIJ_FLAG, RUN_MIJ_OOK_FLAG);
runs.remove((Object) RUN_MIJ_FLAG);
}
@Before
public void runMij() {
assertThat(runs).isEmpty();
runs.add(RUN_MIJ_FLAG);
}
@After
public void runMijAfterOok(RhinoContext context) {
assertThat(runs).containsOnly(RUN_MIJ_OOK_FLAG);
runs.remove((Object) RUN_MIJ_OOK_FLAG);
}
@Before
public void runMijOok(RhinoContext context) {
assertThat(runs).containsOnly(RUN_MIJ_FLAG);
runs.add(RUN_MIJ_OOK_FLAG);
}
@After
public void runMijAfter() {
assertThat(runs).containsOnly(RUN_MIJ_FLAG, RUN_MIJ_OOK_FLAG);
runs.remove((Object) RUN_MIJ_FLAG);
}
@After
public void runMijAfterOok(RhinoContext context) {
assertThat(runs).containsOnly(RUN_MIJ_OOK_FLAG);
runs.remove((Object) RUN_MIJ_OOK_FLAG);
}
public void runMijNiet() {
fail("should not be run");
}
public void runMijNiet() {
fail("should not be run");
}
}

View File

@ -0,0 +1,25 @@
package be.cegeka.junit.jasmine.classes;
import static org.fest.assertions.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import be.cegeka.rhino.RhinoContext;
public class JasmineTestRunnerBeforeAndAfterSuperClass {
static final int RUN_MIJ_FLAG = 0;
static final int RUN_MIJ_OOK_FLAG = 1;
protected List<Integer> runs = new ArrayList<Integer>();
@Before
public void runMijOok(RhinoContext context) {
assertThat(runs).containsOnly(RUN_MIJ_FLAG);
runs.add(RUN_MIJ_OOK_FLAG);
}
}

0
src/test/java/be/cegeka/rhino/ClassInJS.java Executable file → Normal file
View File

View File

View File

0
src/test/java/be/cegeka/rhino/RhinoContextTest.java Executable file → Normal file
View File

0
src/test/javascript/envJsOptions.js Executable file → Normal file
View File

0
src/test/javascript/lib/blank.html Executable file → Normal file
View File

0
src/test/javascript/lib/env.rhino.1.2.js Executable file → Normal file
View File

0
src/test/javascript/lib/env.utils.js Executable file → Normal file
View File

0
src/test/javascript/lib/es5-shim-0.0.4.min.js vendored Executable file → Normal file
View File

0
src/test/javascript/lib/jasmine-1.0.2/MIT.LICENSE Executable file → Normal file
View File

0
src/test/javascript/lib/jasmine-1.0.2/jasmine-html.js Executable file → Normal file
View File

View File

0
src/test/javascript/lib/jasmine-1.0.2/jasmine.css Executable file → Normal file
View File

View File

0
src/test/javascript/lib/jasmine-1.0.2/jasmine.js Executable file → Normal file
View File

View File

0
src/test/javascript/lib/specRunner.tpl Executable file → Normal file
View File

0
src/test/javascript/loadTest.js Executable file → Normal file
View File

0
src/test/javascript/loadTestTwo.js Executable file → Normal file
View File

0
src/test/javascript/sources/source1.js Executable file → Normal file
View File

0
src/test/javascript/sources/source2.js Executable file → Normal file
View File

0
src/test/javascript/specs/crashingJSCode.js Executable file → Normal file
View File

0
src/test/javascript/specs/crashingSpec.js Executable file → Normal file
View File

0
src/test/javascript/specs/emptySpec.js Executable file → Normal file
View File

0
src/test/javascript/specs/failingSpec.js Executable file → Normal file
View File

0
src/test/javascript/specs/spec1.js Executable file → Normal file
View File

0
src/test/javascript/specs/spec2.js Executable file → Normal file
View File