I've ran into some unexpected results running a project with cucumber 2.0+. I discovered when running my tests as Junit, the immediate output doesn't display the "Examples" names or steps, instead it repeats the "Scenario outline" name for each line of "Examples" table. As practice I tried running the demo project for Screenplay pattern "TODOMVC" from https://github.com/serenity-bdd/screenplay-pattern-todomvc, using the following dependencies for cucumber
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
I've tried executing the runner with (CucumberWithSerenity.class) as well as (Cucumber.class)
And this is how the JUNIT looks in my Ecplise.
Junit report in eclipse
Executing the runner using the old info.cukes dependencies (1.2.5) produce result with example names and steps as expected.
Just wondering if anyone else has ran into this issue, or if I'm missing something?
It looks like its intended behavior in the new cucumber version. Sort of a quick-fix solution is to add junit = "--step-notifications" in the cucumberoptions, which will display the steps, but still no luck with showing the example names.
In that case, you have add the below line of code
stepNotifications=true in your TestRunner file
Related
After Selenium, testNG, I just started using Cucumber and Maven. First I created a cucumber project without using <scope>test</scope> for dependency. Like this:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.5.0</version>
</dependency>
But I had a problem. The changes I made in the step definitions were not being applied without building the project. With some research I added this <scope>test</scope> for cucumber. And the problem was solved. (This is also how I resolved a classpath error I got for testng.)
But how does adding scope test make a difference? Why are we adding it?
Our team is making first steps into Kotlin and I'm about to to migrate a test. I tried a first example from mockk (https://github.com/mockk/mockk/blob/master/mockk/common/src/test/kotlin/io/mockk/it/InjectMocksTest.kt). For some reason it seems I'm not able to use kotlin.test although I have added it via maven. Do I have to include any other modules? Or do I have to change something else?
(the mockk example uses Gradle so it doesn't help me).
This is what I'd like to use in my Kotlin test file but it which can't be found (at least not the packages I need):
(Restarting Intellij doesn't help, neither running mvn seperately)
This is my maven dependancy (Intellij shows now error):
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version> <!-- kotlin.version == 1.7.0 -->
<scope>test</scope>
</dependency>
The solution was (see hotkey's answer) to add the following maven dependency:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
You need to add a dependency on one of kotlin-test-junit (for JUnit 4), kotlin-test-junit5 (for JUnit Jupiter), or kotlin-test-testng (for TestNG), depending on what test framework you are using.
The artifact kotlin-test contains only the common code, asserters and other stuff that can be reused across the frameworks.
The kotlin.test annotations like #Test or #BeforeTest are shipped in the test-framework-specific artifacts as typealiases to the actual annotations types of the test frameworks.
I have a spring boot 2 project with maven pom in Intellij
I thought maven uses different internal coverage tools compared to jacoco or something similar
If I click on - Run All Feature in Test with coverage
I get
Error: Could not find or load main class cucumber.api.cli.Main
If I add cucumber dependency (I dont have cucumber based tests or want it)
Exception in thread "main" cucumber.runtime.CucumberException:
No backends were found. Please make sure you have a
backend module on your CLASSPATH.
I just want to run simple spring boot rest based tests with coverage
What setup do I need?
Edit:
I had
Caused by: java.lang.ClassNotFoundException: org.jetbrains.plugins.cucumber.java.run.CucumberJvm3SMFormatter
I needed this in the pom
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
</dependency>
and needed cucumber for java plugin installed
Now everything runs, no errors
BUT no code coverage, it is blank
It's a known issue that JUnit is not suggested from contex menu of project root: https://youtrack.jetbrains.com/issue/IDEA-198762
It appears you have the Cucumber integration installed in IDEA. This adds the option to run all feature files in the root of your project. If you want to run JUnit tests you have to drill down to src/main/test/java and select "Run All Tests".
How to solve the following error message
java.lang.AbstractMethodError:
org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z in
automation project with Java, Selenium Server (having the
configuration : client-combined-3.7.1-sources, client-combined-3.7.1,
commo ns-lang-2.6, org.eclipse.jgit_4.5.0.201609210915-r,
selenium-firefox-driver-3.0.0-beta1, selenium-server-standalone-3.7.1
firefox v. 44)
I have tried many combinations of selenium server & selenium Firefox driver but I was receiving other errors
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.7.1</version>
</dependency>
</dependencies>
Only these lines of code I am using:
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Aila\\Downloads\\geckodriver-v0.19.1-win32\\geckodriver.exe");
driver = new FirefoxDriver();
There are two solution for this isssue:
Adding correct version in Selenium project coz different version don't have same solution for my issue selenium-server-standalone-2.42.2.jar is correct.
This one is optional just try, if any of solution of this issue is not resolve.
Open Windows Command Prompt and type the command below:
java -Dwebdriver.gecko.driver="C:\NewAutomationCICD\resource\chromedriver.exe" -jar C:\NewAutomationCICD\libs\selenium-server-standalone-2.42.2.jar
The error says it all:
java.lang.AbstractMethodError: org.openqa.selenium.MutableCapabilities.is(Ljava/lang/String;)Z in automation project with Java, Selenium Server (having the configuration : client-combined-3.7.1-sources, client-combined-3.7.1, commo ns-lang-2.6, org.eclipse.jgit_4.5.0.201609210915-r, selenium-firefox-driver-3.0.0-beta1, selenium-server-standalone-3.7.1
First of all ensure that you are using all the binaries and jars of latest version (Selenium, GeckoDriver, Firefox Browser).
If you want to use Maven :
Remove all the Selenium related jars which you have added manually from your project.
Use Selenium and TestNG related jars only through Maven Dependencies.
Clean the Project
Execute mvn clean install test
If you want to use Selenium and TestNG without Maven:
Remove all the Selenium related jars once and add only the selenium-server-standalone-3.7.1 within your project.
Clean the Project
Execute your #Test as TestNG Test or TestNG Suite
I am using spring 3.1.0 version api for my project and i have created the test cases for all the layer(web,service,dao).
Execute the test case using mvn test ,it working fine (ie) all the test case are getting passed.
while i am trying to get the code coverage report using mvn emma:emma getting below error.
org.springframework.beans.beanutils.instantiateclass(ljava/lang/class ljava/lang/class)ljava/lang/object
in my pom.xml
for : spring test
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
for : emma plugin
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</dependency>
Please share you thoughts.
Regards
Vasanth D
No need to add any plugin entry in your pom.xml, just run mvn emma:emma. You should be able to generated code coverage report successfully.