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

[SUREFIRE-2026] Improve assertions in Surefire1787JUnit5IT #474

Merged
merged 1 commit into from Feb 25, 2022
Merged
Show file tree
Hide file tree
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 @@ -20,22 +20,14 @@
*/

import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Before;
import org.junit.Test;

import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;

/**
*
*/
@SuppressWarnings( "checkstyle:magicnumber" )
public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase
{
@Before
public void javaVersion()
{
assumeJavaVersion( 1.8d );
}

@Test
public void bothEngines()
Expand All @@ -45,7 +37,9 @@ public void bothEngines()
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Running pkg.JUnit4Test" )
.verifyTextInLog( "Running pkg.JUnit5Test" );
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
}

@Test
Expand All @@ -56,7 +50,10 @@ public void apiAndEngine()
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Running pkg.JUnit4Test" )
.verifyTextInLog( "Running pkg.JUnit5Test" );
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );

}

@Test
Expand All @@ -67,7 +64,9 @@ public void bothApis()
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Running pkg.JUnit4Test" )
.verifyTextInLog( "Running pkg.JUnit5Test" );
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
}

@Test
Expand All @@ -77,7 +76,9 @@ public void selectJUnit4()
.activateProfile( "select-junit4" )
.executeTest()
.verifyErrorFree( 1 )
.verifyTextInLog( "Running pkg.JUnit4Test" );
.verifyTextInLog( "Running pkg.JUnit4Test" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
}

@Test
Expand All @@ -87,7 +88,9 @@ public void selectJUnit5()
.activateProfile( "select-junit5" )
.executeTest()
.verifyErrorFree( 1 )
.verifyTextInLog( "Running pkg.JUnit5Test" );
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
}

@Test
Expand All @@ -98,7 +101,10 @@ public void testNgWithJupiterApi()
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog( "Running pkg.TestNGTest" );
.verifyTextInLog( "Running pkg.TestNGTest" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );

}

@Test
Expand All @@ -109,14 +115,18 @@ public void testNgWithJupiterEngine()
.executeTest()
.verifyErrorFree( 2 )
.verifyTextInLog( "Running pkg.JUnit5Test" )
.verifyTextInLog( "Running pkg.TestNGTest" );
.verifyTextInLog( "Running pkg.TestNGTest" )
.verifyTextInLog(
"Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider" );
}

@Test
public void junit4Runner()
{
unpack( "junit5-runner" )
.executeTest()
.verifyErrorFreeLog();
.verifyErrorFree( 1 )
.verifyTextInLog( "Running pkg.JUnit5Tests" )
.verifyTextInLog( "Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JUnit4Provider is the actual status with the bug in ASM.
It should be JUnitPlatformProvider after the final fix. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is ok IMHO. When we want Junit5 test using Junit4 we add junit-platform-runner as a dependency.
https://junit.org/junit5/docs/current/user-guide/#running-tests-junit-platform-runner

}
}
Expand Up @@ -2,9 +2,13 @@

import org.junit.Test;

class RootTest {
@Test
public void test() {
import static org.junit.Assert.fail;

class RootTest
{
@Test
public void test()
{
fail();
}
}
Expand Up @@ -2,9 +2,11 @@

import org.junit.Test;

public class ATest {
public class ATest
{
@Test
public void test() {

public void test()
{
// ok
}
}
Expand Up @@ -2,9 +2,13 @@

import org.junit.Test;

public class BTest {
@Test
public void test() {
import static org.junit.Assert.fail;

public class BTest
{
@Test
public void test()
{
fail();
}
}