Skip to content

Using with JUnit 5 @RunWith(JUnitPlatform.class) causes multiple deployment. #71

@charleech

Description

@charleech

Using with JUnit 5 @RunWith(JUnitPlatform.class) causes multiple deployment.

Since the JUnit5 does not have the Test Suite and provide the interim solution by the JUnitPlatform which requires the junit:junit:4.13.2 in the classpath.

Then the test suite will be like the following: -

import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.SuiteDisplayName;
import org.junit.runner.RunWith;

/**
 * This is a first test suite.
 */
@RunWith(JUnitPlatform.class)
@SuiteDisplayName("JUnit Platform Suite Demo")
@SelectClasses({
    MyCdiJunit5IntgrtnTester.class
})
@IncludeClassNamePatterns("^(Test.*|.+[.$]Test.*|.*Tests?|.*Tester)$")
public class MyCdiJunit5IntgrtnTestSuite {

}

/**
 * This is a second test suite.
 */
@RunWith(JUnitPlatform.class)
@SuiteDisplayName("JUnit Platform Suite Demo")
@SelectClasses({
    MyCdiJunit5IntgrtnTester.class
})
@IncludeClassNamePatterns("^(Test.*|.+[.$]Test.*|.*Tests?|.*Tester)$")
public class MyCdiJunit5Round2IntgrtnTestSuite {

}

By using it, it causes the Arquillian-Suite-Extension to deploy multiple times (each time for each test suite) !

#
# Only first executed test suite success, all the rest are failed
#
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 28.145 s - in it.test.app.github.charleech.my.cdi.MyCdiJunit5IntgrtnTestSuite

#
# The second test suite causes re-deployment !
#
[INFO] Running it.test.app.github.charleech.my.cdi.MyCdiJunit5Round2IntgrtnTestSuite
May 08, 2021 1:47:43 PM org.eu.ingwar.tools.arquillian.extension.suite.DeploymentClassFinder getDeploymentClassFromAnnotation
INFO: arquillian-suite-deployment: Found class annotated with @ArquillianSuiteDeployment: it.test.app.github.charleech.my.cdi.ArquillianSuiteDeployments
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.016 s <<< FAILURE! - in it.test.app.github.charleech.my.cdi.MyCdiJunit5Round2IntgrtnTestSuite
[ERROR] MyCdiJunit5IntgrtnTester  Time elapsed: 0.015 s  <<< ERROR!
java.lang.RuntimeException: Could not setup GlassFish Embedded Bootstrap
Caused by: org.glassfish.embeddable.GlassFishException: Already bootstrapped

[ERROR] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[ERROR] OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   Could not setup GlassFish Embedded Bootstrap
[INFO]
[ERROR] Tests run: 3, Failures: 0, Errors: 1, Skipped: 0

The reproducer

I've create the reproducer at https://github.com/charleech/arquillian-junit5-payara

How to execute

1.1 The multiple tester without test suite

This is a base line which use pure JUnit 5 without any dependency to JUnit4 and JUnit 5 Platform.

cd path/to/arquillian-junit5-payara

mvn clean install -N

cd path/to/arquillian-junit5-payara/my-cdi-junit5-multiple-tester

mvn clean install -Dpayara-embedded=true

#
# Everything works fine !
#

1.2 The multiple test suite

This is a reproducer which use JUnit 5 with dependency to JUnit4 and JUnit 5 Platform.

cd path/to/arquillian-junit5-payara

mvn clean install -N

cd path/to/arquillian-junit5-payara/my-cdi-junit5-multiple-testsuite

mvn clean install -Dpayara-embedded=true

#
# Only first executed test suite success, all the rest are failed
#
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 28.145 s - in it.test.app.github.charleech.my.cdi.MyCdiJunit5IntgrtnTestSuite

#
# The second test suite causes re-deployment !
#
# ... Could not setup GlassFish Embedded Bootstrap
# ... Already bootstrapped
# ...
# ... Could not setup GlassFish Embedded Bootstrap
#

1.3 My Environment

  • OS: Windows 10 Home Edition 64 Bits
  • JDK: AdoptOpenJDK 1.8.0_292
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
  • Build Tools: Apache Maven 3.8.1
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Java.Application\Apache\apache-maven\bin\..
Java version: 1.8.0_292, vendor: AdoptOpenJDK, runtime: C:\Java.Application\Sun\Java\jdk8u292-b10\jre
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  • Dependencies
    • Arquillian version 1.7.0.Alpha9
    • Arquillian Suite Extension version 1.2.2
    • JUnit4 version 4.13.2
    • JUnit5 version 5.8.0-M1
    • JUnit5 Platform version 1.8.0-M1
    • Payara version 5.2021.3
    • Payara Aqrquillian Container version 2.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions