-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BeforeTestRun resp. AfterTestRun added #2
base: master
Are you sure you want to change the base?
Changes from 5 commits
34b8731
c4e5508
5999199
56e500a
66a7781
6cd1eca
ef4ea70
2e5a0ef
d99c02e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ch.unibe.jexample; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
/** | ||
* | ||
* @author Thilo Ammon | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface AfterTestRun { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ch.unibe.jexample; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
/** | ||
* | ||
* @author amm | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface BeforeTestRun { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,11 +102,22 @@ public Collection<MethodReference> getMethods() { | |
public void run(ExampleClass testClass, RunNotifier notifier) { | ||
if (!anyHasBeenRun) onStartRunning(); | ||
anyHasBeenRun = true; | ||
|
||
for(Method m : testClass.getImplementingClass().getMethods()){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I remember |
||
if (!m.isAnnotationPresent(BeforeTestRun.class)) continue; | ||
Reflection.invoke(m, null); | ||
} | ||
|
||
for (Example e: this.getExamples()) { | ||
if (testClass.contains(e)) { | ||
e.run(notifier); | ||
} | ||
} | ||
|
||
for(Method m : testClass.getImplementingClass().getMethods()){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I remember other example classes may depend on cached results from Have you considered scanning for |
||
if (!m.isAnnotationPresent(AfterTestRun.class)) continue; | ||
Reflection.invoke(m, null); | ||
} | ||
} | ||
|
||
private void onStartRunning() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this file is missing
.java
extension.