Updated Branches: refs/heads/master f9d3640de -> e3015fa0b
o Removed some duplication Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/e3015fa0 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/e3015fa0 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/e3015fa0 Branch: refs/heads/master Commit: e3015fa0be5ba69a9294ecb69dbd9fc160adb709 Parents: f9d3640 Author: Kristian Rosenvold <kristian.rosenv...@gmail.com> Authored: Wed Dec 12 22:55:34 2012 +0100 Committer: Kristian Rosenvold <kristian.rosenv...@gmail.com> Committed: Wed Dec 12 22:55:34 2012 +0100 ---------------------------------------------------------------------- .../surefire/its/fixture/HelperAssertions.java | 5 - .../maven/surefire/its/fixture/MavenLauncher.java | 86 ++++++--------- 2 files changed, 35 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e3015fa0/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java index 22de758..9f14bd7 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java @@ -55,11 +55,6 @@ public class HelperAssertions Assert.assertEquals( "wrong number of skipped", skipped, actualSuite.getSkipped() ); } - public static IntegrationTestSuiteResults parseTestResults( File testDir ) - { - return parseTestResults( new File[]{ testDir } ); - } - public static IntegrationTestSuiteResults parseTestResults( File[] testDirs ) { List<ReportTestSuite> reports = extractReports( testDirs ); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e3015fa0/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java index de69b3c..f31fb85 100755 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java @@ -59,7 +59,6 @@ public class MavenLauncher private boolean expectFailure; - public MavenLauncher( Class testClass, String resourceName, String suffix ) { this.testCaseBeingRun = testClass; @@ -69,7 +68,6 @@ public class MavenLauncher resetCliOptions(); } - public File getUnpackedAt() { return ensureUnpacked(); @@ -103,23 +101,6 @@ public class MavenLauncher } - String getTestMethodName() - { - // dirty. Im sure we can use junit4 rules to attach testname to thread instead - StackTraceElement[] stackTrace = getStackTraceElements(); - StackTraceElement topInTestClass; - topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun ); - if ( topInTestClass == null ) - { - // Look in superclass... - topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun.getSuperclass() ); - } - if ( topInTestClass != null ) - { - return topInTestClass.getMethodName(); - } - throw new IllegalStateException( "Cannot find " + testCaseBeingRun.getName() + "in stacktrace" ); - } private StackTraceElement findTopElemenent( StackTraceElement[] stackTrace, Class testClassToLookFor ) { @@ -222,42 +203,34 @@ public class MavenLauncher return this; } + public FailsafeOutputValidator executeVerify() + { + return new FailsafeOutputValidator( conditionalExec( "verify" ) ); + } + public OutputValidator executeTest() { - try - { - execute( "test" ); - } - catch ( SurefireVerifierException exc ) - { - if ( expectFailure ) - { - return getValidator(); - } - else - { - throw exc; - } - } - if ( expectFailure ) - { - throw new RuntimeException( "Expecting build failure, got none!" ); - } - return getValidator(); + return conditionalExec( "test" ); } - public FailsafeOutputValidator executeVerify() + public OutputValidator executeInstall() + throws VerificationException + { + return conditionalExec( "install" ); + } + + public OutputValidator conditionalExec(String goal) { - OutputValidator verify = null; + OutputValidator verify; try { - verify = execute( "verify" ); + verify = execute( goal ); } catch ( SurefireVerifierException exc ) { if ( expectFailure ) { - return new FailsafeOutputValidator( getValidator() ); + return getValidator(); } else { @@ -268,23 +241,16 @@ public class MavenLauncher { throw new RuntimeException( "Expecting build failure, got none!" ); } - return new FailsafeOutputValidator( verify ); + return verify; } - public OutputValidator executeInstall() - throws VerificationException - { - return execute( "install" ); - } - public MavenLauncher withFailure() { this.expectFailure = true; return this; } - public MavenLauncher addCleanGoal() { addGoal( "clean" ); @@ -459,4 +425,22 @@ public class MavenLauncher { return new File( verifier.getArtifactPath( gid, aid, version, ext ) ); } + + String getTestMethodName() + { + // dirty. Im sure we can use junit4 rules to attach testname to thread instead + StackTraceElement[] stackTrace = getStackTraceElements(); + StackTraceElement topInTestClass; + topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun ); + if ( topInTestClass == null ) + { + // Look in superclass... + topInTestClass = findTopElemenent( stackTrace, testCaseBeingRun.getSuperclass() ); + } + if ( topInTestClass != null ) + { + return topInTestClass.getMethodName(); + } + throw new IllegalStateException( "Cannot find " + testCaseBeingRun.getName() + "in stacktrace" ); + } }