Skip to content

Commit

Permalink
Simplify SurefireHelperTest
Browse files Browse the repository at this point in the history
  • Loading branch information
oehme authored and Tibor17 committed Feb 4, 2021
1 parent 75239c9 commit 1c2e739
Showing 1 changed file with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@

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;

/**
Expand Down Expand Up @@ -125,41 +124,22 @@ public void shouldEscapeWindowsPath()
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
Expand Down

0 comments on commit 1c2e739

Please sign in to comment.