What are dependencies required to integrate cucumber with Extent report and allure report? - cucumber-jvm

I was able to generate extent report with ease by including below dependency for TDD framework using testng-
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.0</version>
</dependency>
However I am now trying to implement it in BDD framework. but unable to do so. What dependencies and properties file I would need to implement Extent report in cucumber.
For allure report I have include below dependency -
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-cucumber-jvm</artifactId>
<version>2.17.3</version>
</dependency>
and Runner file as -
#RunWith(Cucumber.class)
#CucumberOptions(
features = "features"
,glue={"com.learnautomation.stepdefinitions"}
,plugin = {"pretty", "html:target/cucumber-report/index.html", "io.qameta.allure.cucumber6jvm.AllureCucumber6Jvm"} ,
monochrome = true
)
Getting error as below -
Could not load plugin class 'io.qameta.allure.cucumber6jvm.AllureCucumber6Jvm'.
Plugin specifications should have the format of PLUGIN[:[PATH|[URI [OPTIONS]]]

Related

Extent Report is not displaying the data correctly, how can I get it right?

I am using Cucumber for my automation and using Extent Report for generating test reports, After the test is executed, report is generated with report.html name in the target folder. However, when I open the report it does not display the content as it should.
I have used the dependency the below extent report dependency for cucumber:
`<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.2</version>
</dependency>`

How to get the TestNG report in VS Code?

Running selenium test cases with TestNG in VS Code. But the test-output folder is not generated. Tried refreshing the project.
Unlike other IDEs, like Eclipse, etc., VS Code doesn't have a plugin for exclusive TestNG activities. In your case, to generate the TestNG report, you need to have the reporting dependency in your pom.xml:
<dependency>
<groupId>org.testng</groupId>
<artifactId>reportng</artifactId>
<version>1.2.2</version>
<scope>test</scope>
</dependency>

Junit5 test suites with #Suite annotation doesn't execute tests with mvn test command

We intended to upgrade a JUnit4 based project to JUnit5. I modified JUnit4 suites according to the instruction in JUnit5 official site: https://junit.org/junit5/docs/current/user-guide/#running-tests-junit-platform-runner-test-suite.
Tests were not executed when using mvn test in command line: mvn test -Dtest=SuiteXXTest, neither in JUnit4 nor JUnit5 suite.
Error msg: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project XXX: No tests were executed!
Yet both JUnit4 and JUnit5 suites can run and execute the included tests in IDEA. Maven surefire plugin version is 3.0.0-M5. Single test classes(ATest and BTest) are based on JUnit4 progamming model.
Old JUnit4 suite is like this:
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import test.XX.*;
#RunWith(Suite.class)
#Suite.SuiteClasses({
ATest.class,
BTest.class
})
public class SuiteXXTest {
}
Modified to:
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
import test.XX.*;
#Suite
#SelectClasses({
ATest.class,
BTest.class
})
public class SuiteXXTest {
}
related dependencies:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<version>1.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
Curiously, if I use the depracated #RunWith(JUnitPlatform.class) annotation, the test suites can execute properly. But according to JUnit5 official user guide, using this runner means tests will be executed in a JUnit4 envrionment, and I don't understand what condition is regarded as JUnit4 environment(JUnit5 dependency already configured in pom).
I don't known if it's a bug or my incorrect use.
RunWith is a JUnit 4 construct and won’t work with JUnit 5. Use JUnit Platform suites instead as described in https://junit.org/junit5/docs/current/user-guide/#junit-platform-suite-engine
Found the solution here: https://github.com/junit-team/junit5/discussions/2753.
According to this answer I just changed my command from -Dtest=SuiteXXTest to -Dinclude=SuiteXXTest and it works fine. I think it has something to do with the surefire plugin. It seems surefire cannot pick up tests form suite annotated with #Suite when using -Dtest command.

JUnit on IntelliJ not working

I tried setting up JUnit 5 on my INtelliJ IDEA Community Edition 2018.2. The jar was downloaded but I am getting Cannot resolve symbol Assertions on importing
import static org.junit.jupiter.api.Assertions.*;
Error
Are you trying to use the JUnit assertions in a regular app class rather than a test class?
Delete <scope>test</scope>
When a Maven dependency carries a scope element with a value of test, that means you cannot use that library outside of your test-specific source package/folder.
If you are trying to call JUnit from code in your example project’s src/main/java/… folder hierarchy, you will see that error. If you call JUnit from src/test/java…, you will see success.
To enable JUnit in the src/main/java/… folder hierarchy, delete the scope element in your POM dependency. So this:
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.0-RC1</version>
<scope>test</scope>
</dependency>
…becomes this:
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.0-RC1</version>
</dependency>
By the way, note that as of 5.4.0 of JUnit, we can specify the new and very convenient single Maven artifact of junit-jupiter which in turn will supply 8 libraries to your project.

How to make IntelliJ understand annotations

I have recently switched from using Eclipse to IntelliJ, and am preferring the experience.
However, the IDE is not understanding any of the Annotations. I am using Spring #Autowired annotation as well as some of the Spring-WS annotations and the IDE is telling me that they are unresolved.
When the project is built using Maven, it builds fine, and the Annotations are recognised in Eclipse.
Im sure this is a simple setup thing, but cannot find any information on how to set it up.
As Peter said, when correctly importing the Maven project the dependencies should be correctly recognized. The IntelliJ manual has a section on how to import a Maven project.
For the record, in our project pom, we have the following dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
The former two have been present already before implementing a web service, so they may not be required strictly for web services.