Serenity report do not have any REST Query - serenity-bdd

We have a serenity and rest assured project.
But the test report does not generate RESTQuery button to check the request response
We query with given().when().body().get(APIURL)
the response comes but no rest query is found.
pom.xml
runner class
package test_suite;
import cucumber.api.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
#RunWith(CucumberWithSerenity.class)
#CucumberOptions(
features = "src/test/resources/features",
plugin = {"pretty"},
glue = {"steps"}
)
public class CucumberTestSuite {
}
api object
#Step
public void HTTPRequest(String ****, String ***8){
String ApiUrl = method(somestring, somestring);
response = given().when().log().body().get(ApiUrl);
//response = RestAssured.get(ApiUrl);
//response = SerenityRest.when().get(ApiUrl);
}
Error while checking with SerenityRest
net.serenitybdd.core.exceptions.SerenityManagedException: net.serenitybdd.rest.decorators.request.RequestSpecificationDecorated.getDefinedFilters()Ljava/util/List;
IT worked now with serenity version 1.9.26
IT worked now with serenity version 1.9.26

Related

Java Selenium 'Cannot resolve symbol Test' TestNG

I have a problem with TestNG. I cannot run a test.
I am getting this error:
POM.xml has no errors.
Here is the code in test page:
import Pages.SearchPage;
import org.testng.annotations.Test;
import core.Web.AllListeners.*;
public class Search extends Listener {
#Test(groups = "Regression")
public void ticketBookingFunctionality() {
new SearchPage()
.openUrl()
.inputCaption("Comic")
.selectCityByValue()
.inputDateFrom("2020-01-01")
.inputDateTo("2021-07-05")
.clickButtonSearch()
.clickButtonBuy()
.chooseTicket()
.choosePrice()
.pushButtonFindTickets()
.closeLoginPopup();
}
}
Where can be the problem?
You need to add the following testng related jar files within your project.

RestAssured - Testing Restful API using Selenium and Test NG - when run throws connection timeout error

I am testing a Weather Rest API using Restassured and TestNG framework. Following is the code:
I made sure I have all the dependencies covered in pom.xml file
This is the error:
java.lang.NoSuchMethodError: org.testng.remote.AbstractRemoteTestNG.addListener(Lorg/testng/ISuiteListener;)V
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:122)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
public class RestApi_Weather_GET {
#Test
void GetWeatherDetails(){
//specify the base uri
RestAssured.baseURI = "http://restapi.demoqa.com/utilities/weather/city/";
//Request object is being created
RequestSpecification ahttprequest = RestAssured.given();
//Response object
Response aresponse = ahttprequest.request(Method.GET, "Alameda");
//print response in console
String aresponseBody = aresponse.getBody().asString();
System.out.println("Response body is : "+aresponseBody);
}
}

How to run Karate from java application not from JUnit test

I managed to run Karate tests using Junit. But what I want is to run Karate from java application instead of Junit runner.
Currently I'am running from JUnit:
import com.intuit.karate.cucumber.CucumberRunner;
import com.intuit.karate.cucumber.KarateStats;
import cucumber.api.CucumberOptions;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
#CucumberOptions(tags = {"~#ignore"})
public class TestParallel {
#Test
public void testParallel() {
KarateStats stats = CucumberRunner.parallel(getClass(), 5, "target/surefire-reports");
assertTrue("scenarios failed", stats.getFailCount() == 0);
}
}
I tried calling the Junit class from my application main using the code below:
JUnitCore junit = new JUnitCore();
Result result = junit.run(TestParallel.class);
But I have this error:
java.lang.NoClassDefFoundError: com/intuit/karate/cucumber/CucumberRunner
Yes, please use the Java API, documented here: https://github.com/intuit/karate#java-api
Note that you won't get reports if you go down this path.
I solved the problem by removing the test scope from the karate dependencies in the pom.
Everything works fine including the reports and the output.

Cucumber Test runner issue

I have below format for test runner but it is giving no feature file found while running the junit runner.Please attached the screenshot of locations of the step definition and feature file
import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
#RunWith(Cucumber.class)
#Cucumber.Options(
features ={"C:\\Users\\workspace\\Project3\\src\\qa2qe\\Features\\shipping.feature"},
format = {"pretty"},
tags = {"#testscenario1"}
)
public class ShippingTest {
}

How to implement and run cucumber test files using testng

Trying to implement selenium + Cucumber + Testng instead of Junit.
My queries are
What is the alternate for #Runwith(Cucumber.class) in testng
How to run the class file which contains the path to feature file
package runner;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
#CucumberOptions(features="src/main/java/testCases/Cucumber/Login_Cucumber.Feature",glue="")
public class TestRunner extends AbstractTestNGCucumberTests {
}
TestNg uses #CucumberOptions tag to declare parameters
#CucumberOptions(plugin = "json:target/cucumber-report.json")
public class RunCukesTest extends AbstractTestNGCucumberTests {
}
or
#CucumberOptions(features = "src/test/resources/features/Download.feature",
glue = "uk.co.automatictester.jwebfwk.glue",
format = {"pretty"})
Check this out: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
Also a possible dup of :How to integrate the cucumber in testNG?
Install TestNG Eclipse Plugin. Afterwards you should be able to run TestNG Test.
First of all, Cucumber have .feature files and not test files.
Answer to your first question: 1. What is the alternate for #Runwith(Cucumber.class) in testng? "You don't need #RunWith while running with TestNG"
I didn't understand your second question but you need to understand that Cucumber runs end execute the Runner class by default and you have already defined feature files in #CucumberOptions section.
To make it more clear you can easily implement and Run Cucumber project using TestNG. The whole game is in your pom.xml file and Runner class.
Following detail also explains that you can run each scenario in cucumber as a test using TestNG.
How? It's explained below:
First of all, update your Cucumber Maven dependencies from info.cukes to io.cucumber dependencies
Following Java code in Cucumber Runner Class worked perfectly for me to run each scenario as TestNG test in feature files:
#CucumberOptions(features = "src/test/resources", plugin = "json:target/cucumber-report-feature-composite.json")
public class TestRunner {
private TestNGCucumberRunner testNGCucumberRunner;
#BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}
#Test(groups = "cucumber scenarios", description = "Runs Cucumber
Scenarios", dataProvider = "scenarios")
public void scenario(PickleEventWrapper pickleEvent, CucumberFeatureWrapper
cucumberFeature) throws Throwable{
testNGCucumberRunner.runScenario(pickleEvent.getPickleEvent());
}
#DataProvider
public Object[][] scenarios() {
return testNGCucumberRunner.provideScenarios();
}
#AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
testNGCucumberRunner.finish();
}
}
Run with mvn clean test command and see the magic :)
I would be happy to see your problem resolved. Please let me know if this issue is still not resolved.
Reference: https://github.com/cucumber/cucumber-jvm/blob/master/testng/README.md
I followed this approach: https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesByCompositionTest.java
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
#CucumberOptions(features="src/test/resources/features",glue="stepDefinitions",tags="#Test01",plugin= {"pretty", "html:target/cucumber-reports" },monochrome=true)
public class RunnerTest extends AbstractTestNGCucumberTests{
}
It will work for sure.
This perfectly worked for me
package com.shyom.cucumberOptions;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
#CucumberOptions(
plugin = "json:target/cucumber-report.json",
features = "/shyom/src/test/java/feature",
glue="stepDefinations"
)
public class TestRunner extends AbstractTestNGCucumberTests{
}