Skip to content
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

Failure of a test run should cause build failure #55

Merged
merged 1 commit into from Aug 29, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -219,6 +219,9 @@ public void doWithDevice(final IDevice device) throws MojoExecutionException, Mo
if (testRunListener.hasFailuresOrErrors()) {
throw new MojoFailureException("Tests failed on device.");
}
if (testRunListener.testRunFailed()) {
throw new MojoFailureException("Test run failed to complete: "+testRunListener.getTestRunFailureCause());
}
if (testRunListener.threwException()) {
throw new MojoFailureException(testRunListener.getExceptionMessages());
}
Expand Down Expand Up @@ -285,6 +288,7 @@ private class AndroidTestRunListener implements ITestRunListener {
private int testCount = 0;
private int testFailureCount = 0;
private int testErrorCount = 0;
private String testRunFailureCause = null;

private final MavenProject project;
/** the emulator or device we are running the tests on **/
Expand Down Expand Up @@ -492,6 +496,7 @@ public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
}

public void testRunFailed(String errorMessage) {
testRunFailureCause = errorMessage;
getLog().info(INDENT +"Run failed: " + errorMessage);
}

Expand Down Expand Up @@ -599,6 +604,17 @@ public boolean hasFailuresOrErrors() {
return testErrorCount > 0 || testFailureCount > 0;
}

/**
* @return if the test run itself failed - a failure in the test infrastructure, not a test failure.
*/
public boolean testRunFailed() {
return testRunFailureCause != null;
}

public String getTestRunFailureCause() {
return testRunFailureCause;
}

/**
* @return if any exception was thrown during the test run
* on the build system (not the Android device or emulator)
Expand Down