I have JUnit tests that have a rest-assured dependency.
How can I run these in Gradle?
I have no idea what you mean by 'rest assured' tests but I'll assume you just want to run either JUnit or TestNG tests in gradle. You should really remove any maven references from your question to avoid confusion... this is a simple Gradle question and has nothing to do with Maven.
The following line in your build.gradle
apply plugin: java
Adds the java plugin to your build which adds appropriate test tasks to your build. Please see the java plugin documentation for configuring JUnit / TestNG
Related
I have a Maven project that contains both JUnit 4 and JUnit 5 tests.
I am using the Maven Surefire plugin in version 3.0.0-M07. The following relevant dependencies are available in the Maven dependency tree (I checked with mvn dependency:tree):
org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
org.junit.platform:junit-platform-commons:jar:1.8.2:test
org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
junit:junit:jar:4.13.2:test
According to the JUnit 5 documentation, the JUnit Vintage Engine needs to be present to execute JUnit 4 tests.
However, the Maven Surefire plugin executes both the JUnit 4 and JUnit 5 tests.
Why is the Maven Surefire plugin able to execute JUnit 4 tests, even though there is no dependency on the JUnit Vintage Engine in my Maven project?
By using junit-jupiter-api maven-surefire-plugin/maven-failsafe-plugin loads the junit-vintage-engine automatically and executes JUnit 4 based tests.
The correct way is to use the junit-jupiter-engine instead of junit-jupiter-api. This is explained in the surefire documentation
An deep explanation is available here.
I am writing Cucumber Automated Test Cases in java, using REST Assured.
All the tests run as JUnit tests, & as Gradle tests, & they all pass successfully.
The next step I need to take is to generate a Cucumber Report based on these test results.
I've been told that I need to find a gradle plugin for cucumber.
So far, I've tried putting the following code (from here: https://plugins.gradle.org/plugin/com.github.spacialcircumstances.gradle-cucumber-reporting) into my build.gradle file:
plugins {
id "com.github.spacialcircumstances.gradle-cucumber-reporting" version "0.0.12"
}
But, when I try to refresh the gradle, I get this error:
Sychrnoize Gradle projects with workspace failed due to an error in the referenced Gradle build.
Is this the correct plugin to generate this cucumber report, and if so, why is it not being accepted by the gradle?
TFS and TestNG - Possible to Execute TestNG test(s) within TFS2015?
I have uploaded a Java Maven project to a Repo in my instance of TFS.
My java Maven project comprises of TestNG Test / classes
I can see that there is a Maven plugin within the TFS which also has a JUnit link.
4. I cant see any option to enable me to execute TestNG tests within the TFS, is it even possible?
It's able to use Maven task to build a Java application or test the application including TestNG test. Detail steps please refer this tutorial: Get started testing Java applications with Visual Studio Team Services
For test result report just follow juherr's reply in this question.
Yes you should be able to run your TestNG tests.
I think its eventually going to be Maven that is going to be executing your tests.
Maven makes use of surefire-plugin to basically execute your tests. For TestNG here's two of executing tests via surefire-plugin
If your test matches the default pattern "/Test*.java", "/*Test.java", "**/*TestCase.java" (See here)
Create a suite xml file for TestNG (See here) and have surefire plugin refer to it (see here).
I use Gradle for building my project and I have some trouble between cucumber and gradle. For example:
I have a feature file, which I run with JUnit RunWith annotation. But if I want to run 1 scenario by tag, I write this:
-Dcucumber.options= --tags #1 #2 and try to run it.
But Gradle doesn't see this command and runs all tests. So, how can I correctly apply cucumber plugin into Gradle?
So, I found one way to do it. All we need is to use testCompile with JUnit, not cucumber-junit and all is right.
I am working on a Maven project and am trying to exclude some tests that should not run in the build phase. However, all the guides I can find give instructions for how to exclude either through command line arguments or with the Surefire plugin. Isn't there a way to exclude the file through the pom.xml without using Surefire, as I'm not using Surefire to run the unit tests in the first place? Where would this exclusion go?
Surefire is the name of the framework for executing tests (it's an abstraction layer for the specific tool). It support JUnit, TestNG and others. To exclude tests by pom.xml, have a look at http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html