Commit 5f290447 authored by plokhande's avatar plokhande

Initial commit

parents
File added
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="test1" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test1</groupId>
<artifactId>test1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<cucumber.version>6.8.1</cucumber.version>
<junit.version>4.13</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</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>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
File added
import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class AmazonSearchSteps {
private WebDriver driver;
@Before
public void setUp(){
// System.setProperty("webdriver.chrome.driver", "/Applications/chrome driver");
driver= new ChromeDriver();
}
@After
public void tearDown(Scenario scenario){
/*if(scenario.isFailed()){
final byte screenshot=((TakeScreenshot)driver).getScreenshotAs(OutputType.BYTES);
}*/
closeBrowser();
}
@Given("I navigated to Google")
public void i_navigated_to_google() throws Throwable {
// Write code here that turns the phrase above into concrete actions
driver.get("http://www.google.com");
}
@When("I searched for Amazon")
public void i_searched_for_amazon() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
@Then("the result should show for Amazon")
public void the_result_should_show_for_amazon() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
void closeBrowser(){
driver.quit();
}
}
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class CatFactsSteps {
private String url;
private Response response;
@Given("^the client makes a call to the hero ku$")
public void the_client_makes_a_call_to_the_hero_ku() throws Throwable {
// Write code here that turns the phrase above into concrete actions
url = "https://cat-fact.herokuapp.com";
}
@When("^the user calls the api for facts$")
public void the_user_calls_the_api_with_facts() throws Throwable {
// Write code here that turns the phrase above into concrete actions
//response = restTemplate.getForEntity(new URI(url+"/facts"), String.class);
response = RestAssured.given().baseUri(url).basePath("/facts").get().then().log().status().extract().response();
}
@Then("^the client receives status of (\\d+)$")
public void the_client_receives_status_of(int arg1) throws Throwable {
// Write code here that turns the phrase above into concrete actions
assertEquals(arg1, response.getStatusCode());
}
@Then("^the response has the text$")
public void the_response_has_the_text(DataTable data) throws Throwable {
// Write code here that turns the phrase above into concrete actions
// For automatic transformation, change DataTable to one of
// List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.
// E,K,V must be a scalar (String, Integer, Date, enum etc)
List<Map<String, String>> rows = data.asMaps(String.class, String.class);
for (Map<String, String> row : rows) {
String text = row.get("text");
assertTrue(response.getBody().asString().indexOf(text) > 0);
}
}
}
\ No newline at end of file
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"pretty",
"html:target/surefire-reports/html",
"json:target/surefire-reports/json/report.json",
"junit:target/surefire-reports/junit/report.xml"
},
monochrome = true,
tags = "@wip")
public class RunCucumberTest {
}
@wip
Feature: Google
As a user
I want to navigate to Google
So that I can search for Amazon
Scenario: Search Amazon
Given I navigated to Google
When I searched for Amazon
Then the result should show for Amazon
@hip
Feature: Test Cat Facts API
Scenario: User initiates a request to get facts about cats
Given the client makes a call to the hero ku
When the user calls the api for facts
Then the client receives status of 200
And the response has the text
| text |
| Cats make more than 100 different sounds whereas dogs make around 10. |
| Owning a cat can reduce the risk of stroke and heart attack by a third. |
\ No newline at end of file
This diff is collapsed.
[
{
"line": 2,
"elements": [
{
"start_timestamp": "2022-02-24T00:10:42.111Z",
"before": [
{
"result": {
"duration": 2526000000,
"status": "passed"
},
"match": {
"location": "AmazonSearchSteps.setUp()"
}
}
],
"line": 7,
"name": "Search Amazon",
"description": "",
"id": "google;search-amazon",
"after": [
{
"result": {
"duration": 92000000,
"status": "passed"
},
"match": {
"location": "AmazonSearchSteps.tearDown(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario",
"steps": [
{
"result": {
"duration": 1372000000,
"status": "passed"
},
"line": 8,
"name": "I navigated to Google",
"match": {
"location": "AmazonSearchSteps.i_navigated_to_google()"
},
"keyword": "Given "
},
{
"result": {
"error_message": "io.cucumber.java.PendingException: TODO: implement me\n\tat AmazonSearchSteps.i_searched_for_amazon(AmazonSearchSteps.java:38)\n\tat ✽.I searched for Amazon(classpath:amazon.feature:9)\n",
"duration": 2000000,
"status": "pending"
},
"line": 9,
"name": "I searched for Amazon",
"match": {
"location": "AmazonSearchSteps.i_searched_for_amazon()"
},
"keyword": "When "
},
{
"result": {
"duration": 1000000,
"status": "skipped"
},
"line": 10,
"name": "the result should show for Amazon",
"match": {
"location": "AmazonSearchSteps.the_result_should_show_for_amazon()"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@wip"
}
]
}
],
"name": "Google",
"description": " As a user\n I want to navigate to Google\n So that I can search for Amazon",
"id": "google",
"keyword": "Feature",
"uri": "classpath:amazon.feature",
"tags": [
{
"name": "@wip",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
]
}
]
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuite errors="0" failures="1" name="io.cucumber.core.plugin.JUnitFormatter" skipped="0" tests="1" time="4.326">
<testcase classname="Google" name="Search Amazon" time="4.063">
<failure message="The scenario has pending or undefined step(s)" type="io.cucumber.java.PendingException"><![CDATA[Given I navigated to Google.................................................passed
When I searched for Amazon..................................................pending
Then the result should show for Amazon......................................skipped
]]></failure>
</testcase>
</testsuite>
@wip
Feature: Google
As a user
I want to navigate to Google
So that I can search for Amazon
Scenario: Search Amazon
Given I navigated to Google
When I searched for Amazon
Then the result should show for Amazon
@hip
Feature: Test Cat Facts API
Scenario: User initiates a request to get facts about cats
Given the client makes a call to the hero ku
When the user calls the api for facts
Then the client receives status of 200
And the response has the text
| text |
| Cats make more than 100 different sounds whereas dogs make around 10. |
| Owning a cat can reduce the risk of stroke and heart attack by a third. |
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment