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

Incompatible class change error #1392

Closed
ghost opened this issue Jun 11, 2018 · 8 comments
Closed

Incompatible class change error #1392

ghost opened this issue Jun 11, 2018 · 8 comments

Comments

@ghost
Copy link

ghost commented Jun 11, 2018

Summary

Tried to run a test after upgrading from Cucumber 2.1.0 to 3.0.2

Expected Behavior

Test runs successfully

Current Behavior

The following exception is thrown:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface cucumber.api.TestCase, but class was expected
	at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter.handleTestCaseStarted(CucumberJvm2SMFormatter.java:80)
	at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter.access$000(CucumberJvm2SMFormatter.java:17)
	at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter$1.receive(CucumberJvm2SMFormatter.java:32)
	at org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter$1.receive(CucumberJvm2SMFormatter.java:30)
	at cucumber.runner.EventBus.send(EventBus.java:28)
	at cucumber.runner.TestCase.run(TestCase.java:37)
	at cucumber.runner.Runner.runPickle(Runner.java:44)
	at cucumber.runtime.Runtime.runFeature(Runtime.java:120)
	at cucumber.runtime.Runtime.run(Runtime.java:106)
	at cucumber.api.cli.Main.run(Main.java:35)
	at cucumber.api.cli.Main.main(Main.java:18)

Possible causes

Here are some of the versions of the dependencies for the project. Maybe related?

        <spring.version>4.3.7.RELEASE</spring.version>
        <cucumber.version>3.0.2</cucumber.version>
        <junit.version>4.12</junit.version>
        <selenium.version>3.7.1</selenium.version>

Environment

Mac OS X
IntelliJIDEA

@mlvandijk
Copy link
Member

Could you please provide the code you are running and how you are running it, so i cam try tp reproduce? Thanks!

@ghost
Copy link
Author

ghost commented Jun 11, 2018

Apologies for not adding this earlier. I'm using a feature file that contains scenarios in gherkin. The scenario steps are linked to step definitions. All written in java using cucumber. The tests were all working fine when I was on Cucumber 2.1.0. However, when I upgraded to Cucumber 3.0.2, I got the error message mentioned above. I think it may be related to multiple choices of the same dependency or an interface becoming a class or vice versa. I have included a more expanded version of my pom file below:

   <name>cucumber-jvm-maven</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-spring</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.22</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.janino</groupId>
            <artifactId>janino</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>${selenium.version}</version>
        </dependency>
............

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jun 11, 2018

This is caused by IDEA's CucumberJvm2SMFormatter. It being the formatter for Cucumber2, runs into a breaking change in Cucumber 3.

image

If you remove --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm2SMFormatter from program arguments in the run configuration it will work again. You'll have to do this until InteliJ fixes their plugin.

@ghost
Copy link
Author

ghost commented Jun 12, 2018

Many thanks, it works fine now

@ghost ghost closed this as completed Jun 12, 2018
@tunovic
Copy link

tunovic commented Jun 21, 2018

@RajaRaviTeja
Copy link

When I have updated cucumber plugin from V1.2.4[info.cukes] to V.4.2.2[io.cucumber] With the below code, i am getting error, The import cucumber.api.java.en.Given(Or When/Then) cannot be resolved
POM.XML

io.cucumber
cucumber-core
4.2.2

            <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.2</version>
            </dependency>
            
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-junit</artifactId>
                <version>4.2.2</version>
                <scope>test</scope>
            </dependency>
            
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-jvm-deps</artifactId>
                <version>1.0.6</version>
                <scope>provided</scope>
            </dependency>
            
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>gherkin</artifactId>
                <version>6.0.14</version>
            </dependency>
            
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>1.10.19</version>
                <scope>test</scope>
            </dependency>
                            
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-testng</artifactId>
                <version>2.0.0</version>
            </dependency>
            
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-picocontainer</artifactId>
                <version>2.1.0</version>
                <scope>test</scope>
            </dependency>

RunFile from where execution is starting
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/functional/",
glue = {"com.jacksparrow.automation.steps_definitions.functional" },
tags = { "@guest_search_in_progress" },
plugin = { "pretty","json:target/cucumber-json/cucumber.json",
"junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
strict = false,
dryRun = false,
monochrome = true)

public class FunctionalRunCuke {
}

Please suggest, what is the mistake

@mlvandijk
Copy link
Member

@RajaRaviTeja Please don't comment on closed issues. If you want help using Cucumber, please try one of the support options.

@cucumber cucumber locked and limited conversation to collaborators Feb 8, 2019
@mlvandijk
Copy link
Member

@RajaRaviTeja But to give a hint: Note that you are using both Junit and TestNG dependencies, and the testng dependency is a different version.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants