Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runner/android_junit_runner/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

* Add logs at the start and end of RunBefore and RunAfters sections to help bug understanding. (b/445754263)

* Ensure @Before and @Test run on the same thread in AndroidJUnit4ClassRunner.

**Breaking Changes**

**API Changes**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ protected Statement withBefores(FrameworkMethod method, Object target, Statement
@Override
protected Statement withAfters(FrameworkMethod method, Object target, Statement statement) {
List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class);
return afters.isEmpty() ? statement : new RunAfters(method, statement, afters, target);
}
Statement combined =
afters.isEmpty() ? statement : new RunAfters(method, statement, afters, target);

/**
* Default to {@link org.junit.Test#timeout()} level timeout if set. Otherwise, set the timeout
* that was passed to the instrumentation via argument.
*/
@Override
protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) {
// test level timeout i.e @Test(timeout = 123)
long timeout = getTimeout(method.getAnnotation(Test.class));

// use runner arg timeout if test level timeout is not present
if (timeout <= 0 && perTestTimeout > 0) {
timeout = perTestTimeout;
}

if (timeout <= 0) {
// no timeout was set
return next;
if (timeout > 0) {
// Cannot switch to use builder as that is not supported in JUnit 4.10 which is what is
// available in AOSP.
@SuppressWarnings("deprecation")
var failOnTimeout = new FailOnTimeout(combined, timeout);
return failOnTimeout;
}
return combined;
}

// Cannot switch to use builder as that is not supported in JUnit 4.10 which is what is
// available in AOSP.
return new FailOnTimeout(next, timeout);
/**
* Default to {@link org.junit.Test#timeout()} level timeout if set. Otherwise, set the timeout
* that was passed to the instrumentation via argument.
*/
@Override
protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) {
return next;
}

private long getTimeout(Test annotation) {
Expand Down
Loading