This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 1c2e73918b2053470a2cd5489e6be428f9705a02 Author: Stefan Oehme <[email protected]> AuthorDate: Mon Feb 1 14:20:15 2021 +0100 Simplify SurefireHelperTest --- .../maven/plugin/surefire/SurefireHelperTest.java | 42 ++++++---------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java index fb4033d..f190f03 100644 --- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java +++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SurefireHelperTest.java @@ -32,11 +32,10 @@ import java.util.List; import static java.util.Collections.addAll; import static java.util.Collections.singleton; -import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS; import static org.apache.maven.plugin.surefire.SurefireHelper.escapeToPlatformPath; import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution; +import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS; import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; /** @@ -125,41 +124,22 @@ public class SurefireHelperTest public void shouldHandleFailIfNoTests() throws Exception { RunResult summary = new RunResult( 0, 0, 0, 0 ); - try - { - Mojo plugin = new Mojo(); - plugin.setFailIfNoTests( true ); - reportExecution( plugin, summary, null, null ); - } - catch ( MojoFailureException e ) - { - assertThat( e.getLocalizedMessage() ) - .isEqualTo( "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); - return; - } - fail( "Expected MojoFailureException with message " - + "'No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)'" ); + Mojo plugin = new Mojo(); + plugin.setFailIfNoTests( true ); + e.expect( MojoFailureException.class ); + e.expectMessage( "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); + reportExecution( plugin, summary, null, null ); } @Test public void shouldHandleTestFailure() throws Exception { RunResult summary = new RunResult( 1, 0, 1, 0 ); - try - { - reportExecution( new Mojo(), summary, null, null ); - fail( "Expected MojoFailureException with message " - + "'There are test failures.\n\nPlease refer to null " - + "for the individual test results.\nPlease refer to dump files (if any exist) " - + "[date].dump, [date]-jvmRun[N].dump and [date].dumpstream.'" ); - } - catch ( MojoFailureException e ) - { - assertThat( e.getLocalizedMessage() ) - .isEqualTo( "There are test failures.\n\nPlease refer to null " - + "for the individual test results.\nPlease refer to dump files (if any exist) " - + "[date].dump, [date]-jvmRun[N].dump and [date].dumpstream." ); - } + e.expect( MojoFailureException.class ); + e.expectMessage( "There are test failures.\n\nPlease refer to null " + + "for the individual test results.\nPlease refer to dump files (if any exist) " + + "[date].dump, [date]-jvmRun[N].dump and [date].dumpstream." ); + reportExecution( new Mojo(), summary, null, null ); } @Test
