Vishnu Ramesh
Vishnu Ramesh

Reputation: 1

Maven Test runs indefinitely on a Test Suite which executes fine in Junit4

I recently mavenized few old projects. When I am trying to build caffeine tests project with maven build, the test suite hangs when it executes the first test.

I debugged the application, it adds all the tests in the test suite but when it tries to execute the first test, it hangs and the stack frame disappears. But the remote java application doesn't crash, it just waits forever.

But all the tests runs perfectly when running in Junit4.

It hangs exactly at this Stack Frame Stack frame hangs at CaffeineLauncher(TestCase).runBare()

Stack Frame gets erased after this Stack Frame gets erased after this

Remote Java Application Debugging.

C:\Users\***\Caffeine Tests\src\main\resources>mvnDebug -DforkCount=0 test
Listening for transport dt_socket at address: 8000
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< caffeine-tests:caffeine-tests >--------------------
[INFO] Building caffeine-tests 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ caffeine-tests ---
[INFO] skip non existing resourceDirectory C:\Users\***\Caffeine Tests\src\main\resources
[INFO]
[INFO] --- compiler:3.13.0:compile (default-compile) @ caffeine-tests ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ caffeine-tests ---
[INFO] skip non existing resourceDirectory C:\Users\***\Caffeine Tests\src\main\resources
[INFO]
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ caffeine-tests ---
[INFO] Nothing to compile - all classes are up to date.
[INFO]
[INFO] --- surefire:3.3.0:test (default-test) @ caffeine-tests ---
[WARNING] useSystemClassLoader setting has no effect when not forking
[WARNING] The parameter forkCount should likely not be 0. Forking a JVM for tests improves test accuracy. Ensure to have a <forkCount> >= 1.
[INFO] Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider
[INFO] Running caffeine.test.TestCaffeine

Test Caffeine

package caffeine.test;

import junit.framework.Test;
import junit.framework.TestSuite;

public final class TestCaffeine extends junit.framework.TestSuite {
    public TestCaffeine() {
        super();
    }
    public TestCaffeine(final Class theClass) {
        super(theClass);
    }
    public TestCaffeine(final String name) {
        super(name);
    }
    public static Test suite() {
        final TestCaffeine suite = new TestCaffeine();

            suite.addTest(new TestSuite(
                caffeine.test.aggregation3.CaffeineLauncher.class));
            suite
                .addTest(new TestSuite(caffeine.test.array.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.association1.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.association2.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.collection.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition1.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition2.CaffeineLauncher.class));
        suite.addTest(new TestSuite(
            caffeine.test.composition3.CaffeineLauncher.class));
        suite.addTest(new TestSuite(
            caffeine.test.composition4.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition5.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition6.counterexample.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition7.counterexample.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition8.counterexample.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.composition9.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.interactiondiagram1.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.interactiondiagram2.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.multithreading1.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.multithreading2.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.nextEvent2.CaffeineLauncher.class));
            suite.addTest(new TestSuite(
                caffeine.test.nextEvent3.CaffeineLauncher.class));

        return suite;
    }
}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>net.ptidej</groupId>
        <artifactId>all-ptidej</artifactId>
        <version>1.0.0</version>
    </parent>
    <groupId>caffeine-tests</groupId>
    <artifactId>caffeine-tests</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <release>21</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.3.0</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.ptidej.caffeine</groupId>
            <artifactId>caffeine</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>

I cleaned all the projects, updated maven projects but no Idea why it could possibly get stuck.

Upvotes: 0

Views: 34

Answers (0)

Related Questions