From 924815a22053ffd70b3cab5db56676463d93a375 Mon Sep 17 00:00:00 2001 From: Avi Stramer Date: Sun, 10 Jan 2021 01:29:25 -0600 Subject: [PATCH 1/5] update example to testable-selenium-java 0.0.11 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d6751c6..ee56e02 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,6 @@ repositories { } dependencies { - implementation 'io.testable:testable-selenium-java:0.0.9' + implementation 'io.testable:testable-selenium-java:0.0.11' testImplementation 'junit:junit:4.13' } From b3a17fd2eeab0e7169803717c630bc7421b95ef5 Mon Sep 17 00:00:00 2001 From: Avi Stramer Date: Sun, 24 Jan 2021 12:44:17 -0600 Subject: [PATCH 2/5] 0.0.12 testable-selenium-java --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ee56e02..05c39ca 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,6 @@ repositories { } dependencies { - implementation 'io.testable:testable-selenium-java:0.0.11' + implementation 'io.testable:testable-selenium-java:0.0.12' testImplementation 'junit:junit:4.13' } From 4fb7d3548aa10e6d7aead070bae4f069186b6e86 Mon Sep 17 00:00:00 2001 From: Aamir Mahmood <67591625+aamirtestable@users.noreply.github.com> Date: Thu, 18 Aug 2022 02:58:02 +0500 Subject: [PATCH 3/5] version bumped (#2) --- build.gradle | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 05c39ca..f123253 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,22 @@ group 'io.testable' version '0.1.0-SNAPSHOT' apply plugin: 'java' +apply plugin: 'application' repositories { mavenCentral() } dependencies { - implementation 'io.testable:testable-selenium-java:0.0.12' + implementation 'io.testable:testable-selenium-java:0.0.21' + implementation 'com.google.guava:guava:30.1.1-jre' testImplementation 'junit:junit:4.13' } + +application { + mainClassName = "io.testable.selenium.TestableExample" +} + +run { + systemProperties System.getProperties() +} From 9624c6eccda51c088a7724896856b85e8f99d96d Mon Sep 17 00:00:00 2001 From: avistramer Date: Wed, 17 May 2023 17:43:16 -0500 Subject: [PATCH 4/5] updates --- .gitignore | 1 + README.md | 20 ++-- build.gradle | 41 +++++++- pom.xml | 94 +++++++++++++++++++ .../MainSampleTest.java} | 5 +- .../io/testable/example/JUnitSampleTest.java | 20 ++++ .../io/testable/example/TestNGSampleTest.java | 21 +++++ src/test/resources/testng.xml | 9 ++ 8 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 pom.xml rename src/main/java/io/testable/{selenium/TestableExample.java => example/MainSampleTest.java} (83%) create mode 100644 src/test/java/io/testable/example/JUnitSampleTest.java create mode 100644 src/test/java/io/testable/example/TestNGSampleTest.java create mode 100644 src/test/resources/testng.xml diff --git a/.gitignore b/.gitignore index 6695bd7..7a7dca1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ gradle/ gradlew gradlew.bat gradle.properties +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 1e0484c..c8937c6 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -Examples showing how to utilize [testable-selenium-java](https://github.com/testable/testable-selenium-java). +Examples showing how to utilize [testable-selenium-java](https://github.com/testable/testable-selenium-java) and how to run tests on Testable. +This includes via main class, JUnit, and TestNG and built via either Maven or Gradle. -When running on Testable, if the project source is uploaded as a zip file -or linked to version control either Gradle or Mabe used to do a build -by auto-detecting a build.gradle or pom.xml file -in the root of the repository. If both are detected, Gradle will be used. +Examples: -Testable will run the main class specified in the scenario on the test runner. \ No newline at end of file +* `MainSampleTest`: Main class that loads Google and takes a screenshot. +* `JUnitSampleTest`: JUnit test that loads Google and takes a screenshot. +* `TestNGSampleTest`: TestNG test that loads Google and takes a screenshot. + +There a variety of ways to run this on Testable: + +* Upload a jar and specify the main class or test classes +* Upload an executable jar that runs your main class +* Upload this project in a zip file. Choose Gradle or Maven as the build tool and specify the right goals: + * `Gradle`: `build test` (for JUnit/TestNG) or `build run` (for main class) + * `Maven`: `test` (for JUnit/TestNG) or `compile exec:exec` (for main class) diff --git a/build.gradle b/build.gradle index 05c39ca..f891182 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,46 @@ +plugins { + id 'application' + id 'java' +} + group 'io.testable' version '0.1.0-SNAPSHOT' -apply plugin: 'java' - repositories { mavenCentral() } dependencies { - implementation 'io.testable:testable-selenium-java:0.0.12' - testImplementation 'junit:junit:4.13' + implementation 'io.testable:testable-selenium-java:0.0.24' + implementation 'com.google.guava:guava:30.1.1-jre' + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.testng:testng:6.14.3' +} + + +application { + mainClass = 'io.testable.example.MainSampleTest' +} + +tasks.named('test') { + if (Boolean.getBoolean("isTestNG")) + useTestNG() + else + useJUnit() +} + +tasks.register('uberTestJar', Jar) { + dependsOn testClasses + manifest { + attributes 'Main-Class': 'io.testable.example.MainSampleTest' + } + sourceSets.main.output.each { + from it + } + sourceSets.test.output.each { + from it + } + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { configurations.testRuntimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + with jar } diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..746870b --- /dev/null +++ b/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + io.testable + testable-selenium-java-example + 0.1.0-SNAPSHOT + + + io.testable + testable-selenium-java + 0.0.24 + + + com.google.guava + guava + 30.1.1-jre + + + junit + junit + 4.13.2 + test + + + org.testng + testng + 6.14.3 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.0 + + + + junit + false + + + 1 + + + + org.apache.maven.surefire + surefire-junit47 + 3.1.0 + + + org.apache.maven.surefire + surefire-testng + 3.1.0 + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + + exec + + + + + java + + -classpath + + io.testable.example.MainSampleTest + + + + + + + + \ No newline at end of file diff --git a/src/main/java/io/testable/selenium/TestableExample.java b/src/main/java/io/testable/example/MainSampleTest.java similarity index 83% rename from src/main/java/io/testable/selenium/TestableExample.java rename to src/main/java/io/testable/example/MainSampleTest.java index 7c19de8..5b638dd 100644 --- a/src/main/java/io/testable/selenium/TestableExample.java +++ b/src/main/java/io/testable/example/MainSampleTest.java @@ -1,12 +1,13 @@ -package io.testable.selenium; +package io.testable.example; +import io.testable.selenium.TestableSelenium; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeOptions; /** * Simple example of loading Google and taking a screenshot in a way that is compatible with the Testable platform. */ -public class TestableExample { +public class MainSampleTest { public static void main(String[] args) { ChromeOptions options = new ChromeOptions(); diff --git a/src/test/java/io/testable/example/JUnitSampleTest.java b/src/test/java/io/testable/example/JUnitSampleTest.java new file mode 100644 index 0000000..248712e --- /dev/null +++ b/src/test/java/io/testable/example/JUnitSampleTest.java @@ -0,0 +1,20 @@ +package io.testable.example; + +import io.testable.selenium.TestableSelenium; +import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeOptions; + +public class JUnitSampleTest { + + @Test + public void testLoadGoogle() { + System.out.println("JUnit test"); + ChromeOptions options = new ChromeOptions(); + WebDriver driver = TestableSelenium.newWebDriver(options); + driver.get("https://www.google.com"); + TestableSelenium.takeScreenshot(driver, "temp.png"); + driver.close(); + } + +} diff --git a/src/test/java/io/testable/example/TestNGSampleTest.java b/src/test/java/io/testable/example/TestNGSampleTest.java new file mode 100644 index 0000000..1ef4ff1 --- /dev/null +++ b/src/test/java/io/testable/example/TestNGSampleTest.java @@ -0,0 +1,21 @@ +package io.testable.example; + +import io.testable.selenium.TestableSelenium; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.testng.annotations.Test; + +public class TestNGSampleTest { + + @Test + public void testLoadGoogle() { + System.out.println("TestNG test"); + ChromeOptions options = new ChromeOptions(); + WebDriver driver = TestableSelenium.newWebDriver(options); + driver.get("https://www.google.com"); + TestableSelenium.takeScreenshot(driver, "temp.png"); + driver.close(); + } + + +} diff --git a/src/test/resources/testng.xml b/src/test/resources/testng.xml new file mode 100644 index 0000000..b310233 --- /dev/null +++ b/src/test/resources/testng.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file From 207bd4bff58090c310f05092d6cd3ea9fafffcc9 Mon Sep 17 00:00:00 2001 From: Avi Stramer Date: Thu, 21 Dec 2023 22:14:14 -0600 Subject: [PATCH 5/5] Update build.gradle --- build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.gradle b/build.gradle index 6b04867..36bd915 100644 --- a/build.gradle +++ b/build.gradle @@ -45,10 +45,6 @@ tasks.register('uberTestJar', Jar) { with jar } -application { - mainClassName = "io.testable.selenium.TestableExample" -} - run { systemProperties System.getProperties() }