mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.61k stars 1.08k forks source link

Adding `mockserver-junit-jupiter` broke junit5 in eclipse #733

Closed skydetulliov closed 4 years ago

skydetulliov commented 4 years ago

I have a maven-based java project that uses spring boot, camel and have some unit tests written with junit5. I run the tests from eclipse (current version). Now I added the mock server dependency in the pom... and eclipse tells me that "No tests found with test runner 'JUnit 5'." If I remove the dependency, everything is good again... Can you help me? Do you have some idea of what is happening?

this is my pom

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>it.skytv.msg</groupId>
    <artifactId>PlaylistValidator</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <camel.version>3.0.1</camel.version>
        <runtime.version>7.32.0.Final</runtime.version>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <!-- https://spring.io/projects/spring-cloud#release-trains -->
                <version>Hoxton.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- Camel BOM -->
            <dependency>
                <groupId>org.apache.camel.springboot</groupId>
                <artifactId>camel-spring-boot-dependencies</artifactId>
                <version>${camel.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- kie BOM -->
            <dependency>
                <groupId>org.kie</groupId>
                <artifactId>kie-bom</artifactId>
                <version>${runtime.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>

        <!-- Enabling health checks -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <!-- SPRING CLOUD -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

        <!-- SLEUTH -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-core</artifactId>
        </dependency>

        <!-- camel -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-jackson-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-activemq-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-xstream</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-http</artifactId>
        </dependency>

        <!-- ActiveMQ -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-camel</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
        </dependency>

        <!-- MSG DB -->
        <dependency>
            <groupId>it.skytv.msg</groupId>
            <artifactId>MsgDbService</artifactId>
            <version>3.0.0</version>
        </dependency>

        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!-- kie -->
        <dependency>
            <groupId>org.kie.server</groupId>
            <artifactId>kie-server-api</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- tests -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.skyscreamer</groupId>
                    <artifactId>jsonassert</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-test-spring-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-junit-jupiter</artifactId>
            <version>5.9.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>spring-boot:run</defaultGoal>

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
amankapoor27 commented 4 years ago

Hi, I am encountering the exact same issue. Is there any workaround/solution for it apart from moving back to Junit4?

@skydetulliov , @jamesdbloom: Any update on this?

skydetulliov commented 4 years ago

@amankapoor27 I couldn't find any workaround, sorry... I was hoping for something from the mock-server people :(

jamesdbloom commented 4 years ago

It is most likely a bug in eclipse and the way it has integrated JUnit5 and is pretty much out of the scope of MockServer. For example, this issue isn't seen in IntelliJ. I can have a look at this issue as some point soon(ish). MockServer is not doing anything specific except including the following dependency:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.5.2</version>
    <scope>compile</scope>
</dependency>
jamesdbloom commented 4 years ago

You could try and see if you explicitly include that dependency likely you'll get the same problem. Then that would prove it is an Ecplise bug or something specific to your project setup.

aman-kapoor27 commented 4 years ago

Hi @skydetulliov and @jamesdbloom , thanks for the quick response, much appreciated.... I will try run the tests via Gradle and also via IntelliJ and will let you guys know if it works...

By the way, I also faced the exact same issue while trying to integrate wire mock in my Junit5 tests, not sure why by it seems a generic issue with using mock servers with junit5..

amankapoor27 commented 4 years ago

Working fine when running with IntelliJ Idea. Also working with gradle using >gradle test command

On Wed, Jun 3, 2020 at 1:06 PM aman-inbetween notifications@github.com wrote:

Hi @skydetulliov https://github.com/skydetulliov and @jamesdbloom https://github.com/jamesdbloom , thanks for the quick response, much appreciated.... I will try run the tests via Gradle and also via IntelliJ and will let you guys know if it works...

By the way, I also faced the exact same issue while trying to integrate wire mock in my Junit5 tests, not sure why by it seems a generic issue with using mock servers with junit5..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mock-server/mockserver/issues/733#issuecomment-638017929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6T6OVNQMJ3WDKLZ6NMEBLRUX4P7ANCNFSM4KZFXSXQ .

jamesdbloom commented 4 years ago

I'm going to close this issue as it is caused by a bug in Eclipse