Skip to content

Commit

Permalink
[SUREFIRE-2055] Always show random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
delanym committed Apr 5, 2022
1 parent daf717e commit 0847b1d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Expand Up @@ -3114,9 +3114,12 @@ protected void warnIfIllegalFailOnFlakeCount() throws MojoFailureException

private void printDefaultSeedIfNecessary()
{
if ( getRunOrderRandomSeed() == null && getRunOrder().equals( RunOrder.RANDOM.name() ) )
if ( getRunOrder().equals( RunOrder.RANDOM.name() ) )
{
setRunOrderRandomSeed( System.nanoTime() );
if ( getRunOrderRandomSeed() == null )
{
setRunOrderRandomSeed( System.nanoTime() );
}
getConsoleLogger().info(
"Tests will run in random order. To reproduce ordering use flag -D"
+ getPluginName() + ".runOrder.random.seed=" + getRunOrderRandomSeed() );
Expand Down
Expand Up @@ -97,7 +97,17 @@ public void testRandomJUnit4SameSeed()
}
}
}


@Test
public void testRandomJUnit4PrintSeed()
{
long seed = 0L;
OutputValidator validator = executeWithRandomOrder( "junit4", seed );
validator.verifyTextInLog( "To reproduce ordering use flag" );
validator = executeWithRandomOrder( "junit4" );
validator.verifyTextInLog( "To reproduce ordering use flag" );
}

@Test
public void testReverseAlphabeticalJUnit4()
throws Exception
Expand Down Expand Up @@ -187,6 +197,16 @@ private OutputValidator executeWithRunOrder( String runOrder, String profile )
.verifyErrorFree( 3 );
}

private OutputValidator executeWithRandomOrder( String profile )
{
return unpack()
.activateProfile( profile )
.forkMode( getForkMode() )
.runOrder( "random" )
.executeTest()
.verifyErrorFree( 3 );
}

private OutputValidator executeWithRandomOrder( String profile, long seed )
{
return unpack()
Expand Down

0 comments on commit 0847b1d

Please sign in to comment.