Add basic setup for cucumber tests in Java
This commit is contained in:
parent
7695b6b3ee
commit
bba9f9ff5d
|
|
@ -0,0 +1,2 @@
|
||||||
|
/SeleniumTests/target/**/*.js
|
||||||
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
/.next/
|
/.next/
|
||||||
/node_modules/
|
/node_modules/
|
||||||
/.idea
|
/.idea
|
||||||
check-syntax.sh
|
check-syntax
|
||||||
|
format
|
||||||
|
server
|
||||||
|
/SeleniumTests/.idea/*
|
||||||
|
/SeleniumTests/*.iml
|
||||||
|
/SeleniumTests/target/*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
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>turnie.re</groupId>
|
||||||
|
<artifactId>selenium-tests</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
|
<artifactId>selenium-java</artifactId>
|
||||||
|
<version>4.0.0-alpha-1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-junit</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-java</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>info.cukes</groupId>
|
||||||
|
<artifactId>cucumber-junit</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package re.turnie.seleniumtests;
|
||||||
|
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
|
|
||||||
|
public class CucumberStepDefinition {
|
||||||
|
|
||||||
|
protected WebDriver driver;
|
||||||
|
|
||||||
|
protected void checkDriverAvailability() {
|
||||||
|
if(driver == null) {
|
||||||
|
SystemConstants.TestBrowser browser = SystemConstants.BROWSER_USED_FOR_TESTS;
|
||||||
|
System.setProperty(browser.getSystemComponentName(), browser.getDriverPath());
|
||||||
|
|
||||||
|
switch (browser) {
|
||||||
|
case Chrome:
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
break;
|
||||||
|
case Firefox:
|
||||||
|
driver = new FirefoxDriver();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("Driver could not be setup.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package re.turnie.seleniumtests;
|
||||||
|
|
||||||
|
import cucumber.junit.Cucumber;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(Cucumber.class)
|
||||||
|
@Cucumber.Options(format = {"pretty", "html:target/cucumber"},
|
||||||
|
features = {"./"})
|
||||||
|
public class RunAll {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package re.turnie.seleniumtests;
|
||||||
|
|
||||||
|
public class SystemConstants {
|
||||||
|
|
||||||
|
public static final String FRONTEND_URL = "";
|
||||||
|
|
||||||
|
public static final TestBrowser BROWSER_USED_FOR_TESTS = TestBrowser.Chrome;
|
||||||
|
|
||||||
|
public enum TestBrowser {
|
||||||
|
Chrome("webdriver.chrome.driver", ""),
|
||||||
|
Firefox("webdriver.gecko.driver", "");
|
||||||
|
|
||||||
|
private String systemComponentName;
|
||||||
|
private String driverPath;
|
||||||
|
|
||||||
|
TestBrowser(String systemComponentName, String driverPath) {
|
||||||
|
this.systemComponentName = systemComponentName;
|
||||||
|
this.driverPath = driverPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSystemComponentName() {
|
||||||
|
return systemComponentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDriverPath() {
|
||||||
|
return driverPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue