Skip to content

Commit

Permalink
new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rozdolsky33 committed Sep 1, 2024
1 parent 3220914 commit c2073cc
Show file tree
Hide file tree
Showing 14 changed files with 419 additions and 0 deletions.
95 changes: 95 additions & 0 deletions src/test/resources/GroovyWithJava.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

classLoader.getClass().name

Java run recognizes only Java StepDefs
Java run uses jdk.internal.loader.ClassLoaders$AppClassLoader

Java run recognizes only Groovy StepDefs
Groovy run uses jdk.internal.loader.ClassLoaders$AppClassLoader

See BackendServiceLoader.loadBackends(Iterable<BackendProviderService> serviceLoader)
serviceLoader contains 2 instances:
JavaBackend
GroovyBackend

Runner constructor
for (Backend backend : backends) {
log.debug(() -> "Loading glue for backend " + backend.getClass().getName());
backend.loadGlue(this.glue, gluePaths);
}
* Issue: JavaBackend.loadGlue() in Lambda it does not go into forEach
* as a result, Java step definitions are not being loaded


FeaturePathFeatureSupplier used by:
Groovy
Java ?

Java run
----
ClassLoader.packages - 4:
"groovyResetJarjarAsm" -> {Package@1135} "package groovyResetJarjarAsm, Groovy Reset Agent, version 1.0.0"
"org.groovy.debug.hotswap" -> {Package@1137} "package org.groovy.debug.hotswap, Groovy Reset Agent, version 1.0.0"
"io.cucumber.core.cli" -> {Package@1139} "package io.cucumber.core.cli, Cucumber-JVM: Core, version 7.18"
"com.intellij.rt.debugger" -> {Package@1141} "package com.intellij.rt.debugger"


Groovy run
----
ClassLoader.packages - 56:
"org.codehaus.groovy.runtime" -> {Package@2049} "package org.codehaus.groovy.runtime, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.slf4j" -> {Package@2051} "package org.slf4j"
"org.codehaus.groovy.jsr223" -> {Package@2053} "package org.codehaus.groovy.jsr223, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.metaclass" -> {Package@2055} "package org.codehaus.groovy.runtime.metaclass, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.control.messages" -> {Package@2057} "package org.codehaus.groovy.control.messages, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.macro.methods" -> {Package@2059} "package org.codehaus.groovy.macro.methods, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.reflection.v7" -> {Package@2061} "package org.codehaus.groovy.reflection.v7, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.lang" -> {Package@2063} "package groovy.lang, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.memoize" -> {Package@2065} "package org.codehaus.groovy.runtime.memoize, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.slf4j.spi" -> {Package@2067} "package org.slf4j.spi"
"org.codehaus.groovy.runtime.powerassert" -> {Package@2069} "package org.codehaus.groovy.runtime.powerassert, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy" -> {Package@2071} "package org.codehaus.groovy, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.transform.trait" -> {Package@2073} "package org.codehaus.groovy.transform.trait, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.ast.expr" -> {Package@2075} "package org.codehaus.groovy.ast.expr, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.lang.groovydoc" -> {Package@2077} "package groovy.lang.groovydoc, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.io" -> {Package@2079} "package org.apache.groovy.io, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.swing.extensions" -> {Package@2081} "package org.apache.groovy.swing.extensions, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.slf4j.simple" -> {Package@2083} "package org.slf4j.simple"
"org.codehaus.groovy.macro.runtime" -> {Package@2085} "package org.codehaus.groovy.macro.runtime, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.util" -> {Package@2087} "package org.apache.groovy.util, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.edushak.testspec" -> {Package@2089} "package org.edushak.testspec"
"org.apache.groovy.nio.extensions" -> {Package@2091} "package org.apache.groovy.nio.extensions, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.datetime.extensions" -> {Package@2093} "package org.apache.groovy.datetime.extensions, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.util" -> {Package@2095} "package groovy.util, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.plugin" -> {Package@2097} "package org.apache.groovy.plugin, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.vmplugin.v8" -> {Package@2099} "package org.codehaus.groovy.vmplugin.v8, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.vmplugin.v9" -> {Package@2101} "package org.codehaus.groovy.vmplugin.v9, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.io" -> {Package@2103} "package groovy.io, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.util.concurrent" -> {Package@2105} "package org.apache.groovy.util.concurrent, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.ast" -> {Package@2107} "package org.codehaus.groovy.ast, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.classgen" -> {Package@2109} "package org.codehaus.groovy.classgen, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.transform" -> {Package@2111} "package groovy.transform, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.reflection" -> {Package@2113} "package org.codehaus.groovy.reflection, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.typehandling" -> {Package@2115} "package org.codehaus.groovy.runtime.typehandling, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.callsite" -> {Package@2117} "package org.codehaus.groovy.runtime.callsite, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.macro.matcher" -> {Package@2119} "package org.codehaus.groovy.macro.matcher, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.reflection.stdclasses" -> {Package@2121} "package org.codehaus.groovy.reflection.stdclasses, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.vmplugin" -> {Package@2123} "package org.codehaus.groovy.vmplugin, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.sql.extensions" -> {Package@2125} "package org.apache.groovy.sql.extensions, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.slf4j.event" -> {Package@2127} "package org.slf4j.event"
"org.slf4j.helpers" -> {Package@2129} "package org.slf4j.helpers"
"org.codehaus.groovy.transform" -> {Package@2131} "package org.codehaus.groovy.transform, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apiguardian.api" -> {Package@2134} "package org.apiguardian.api, apiguardian-api, version 1.1.2"
"org.codehaus.groovy.runtime.wrappers" -> {Package@2136} "package org.codehaus.groovy.runtime.wrappers, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.vmplugin.v10" -> {Package@2138} "package org.codehaus.groovy.vmplugin.v10, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.util" -> {Package@2140} "package org.codehaus.groovy.util, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovyjarjarasm.asm" -> {Package@2142} "package groovyjarjarasm.asm, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.vmplugin.v16" -> {Package@2144} "package org.codehaus.groovy.vmplugin.v16, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.classgen.asm.util" -> {Package@2146} "package org.codehaus.groovy.classgen.asm.util, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.dgmimpl" -> {Package@2148} "package org.codehaus.groovy.runtime.dgmimpl, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.m12n" -> {Package@2150} "package org.codehaus.groovy.runtime.m12n, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.runtime.dgmimpl.arrays" -> {Package@2152} "package org.codehaus.groovy.runtime.dgmimpl.arrays, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"groovy.sql" -> {Package@2154} "package groovy.sql, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.apache.groovy.xml.extensions" -> {Package@2156} "package org.apache.groovy.xml.extensions, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.ast.stmt" -> {Package@2158} "package org.codehaus.groovy.ast.stmt, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
"org.codehaus.groovy.control" -> {Package@2160} "package org.codehaus.groovy.control, Groovy: a powerful, multi-faceted language for the JVM, version 4.0.15"
3 changes: 3 additions & 0 deletions src/test/resources/SpockConfig.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runner {
filterStackTrace false
}
121 changes: 121 additions & 0 deletions src/test/resources/TestSpecConfig.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// This file must have a valid groovy syntax!
// it has *.conf extension only because Geb framework scans entire resources/ dir for groovy files and we do not want that
// TODO: find a way to prevent Geb from scanning this file, then change the extension to *.groovy

import org.testspec.core.TestSpecException
import org.testspec.core.util.WebDriverHelper
import org.openqa.selenium.remote.AbstractDriverOptions
import org.openqa.selenium.remote.RemoteWebDriver
import org.openqa.selenium.WebDriver

import software.amazon.awssdk.services.devicefarm.DeviceFarmClient
import software.amazon.awssdk.services.devicefarm.model.CreateTestGridUrlRequest
import software.amazon.awssdk.services.devicefarm.model.CreateTestGridUrlResponse
import software.amazon.awssdk.regions.Region

import java.awt.Desktop

application = 'demo'
suite = 'smoke'
component = 'misc'

waiting {
includeCauseInMessage = true
timeout = 5 // seconds
retryInterval = 0.5
slow { timeout = 10 }
reallyslow { timeout = 20 }
}

baseDir = System.getProperty('user.dir')
baseNavigatorWaiting = true

// To run the tests with all browsers just run “./gradlew testspec”

environments {
String browserCliParam = System.getProperty('browser')?.toLowerCase()
Map browserParams = WebDriverHelper.parseBrowserArg(browserCliParam)

localhost {
// https://googlechromelabs.github.io/chrome-for-testing/
if (browserParams.name in WebDriverHelper.SUPPORTED_BROWSERS) {
// See: http://code.google.com/p/selenium/wiki/ChromeDriver
driver = {
WebDriver webDriver = WebDriverHelper.supplyDriver(browserParams.name)
// Map<String,String> extraProperties = [:] // user could add more
// WebDriver webDriver = WebDriverHelper.createLocalDriver(browserCliParam, extraProperties)
webDriver.manage().window().maximize()
// manage().window().setSize(new Dimension(1900,1080))
webDriver // must be the last statement in this closure!
}
} else {
throw new TestSpecException("Unsupported browser! Supported: ${WebDriverHelper.SUPPORTED_BROWSERS}")
}
}

saucelabs {
// https://saucelabs.com/platform/platform-configurator#/
driver = {
if (browserParams.name !in WebDriverHelper.SUPPORTED_BROWSERS) {
throw new TestSpecException("Unsupported browser! Supported: ${WebDriverHelper.SUPPORTED_BROWSERS}")
}
String className = "org.openqa.selenium.${browserParams.name.toLowerCase()}.${browserParams.name.capitalize()}Options"
Class clazz = ClassLoader.forName(className)
AbstractDriverOptions options = clazz.getDeclaredConstructor().newInstance()

options.setPlatformName(browserParams.os) // like: "macOS_11.00" "Windows_10"
options.setBrowserVersion(browserParams.version)

Map<String, Object> sauceOptions = [:]
sauceOptions.put('username', System.getenv('SAUCE_USERNAME'));
sauceOptions.put('accessKey', System.getenv('SAUCE_ACCESS_KEY'));
sauceOptions.put('name', 'TestSpec'); // TODO: use app name from this file?

options.setCapability('sauce:options', sauceOptions);
URL url = new URL('https://ondemand.us-west-1.saucelabs.com/wd/hub');

RemoteWebDriver webDriver = new RemoteWebDriver(url, options);

if (Desktop.desktopSupported && Desktop.desktop.isSupported(Desktop.Action.BROWSE)) {
Desktop.desktop.browse(new URI("https://app.saucelabs.com/tests/${webDriver.sessionId}"))
}

webDriver // must be the last statement in this closure!
}
}

amazonfarm {
// AWS device farm setup adds extra 1 min to total execution time
// https://docs.aws.amazon.com/devicefarm/latest/testgrid/getting-started-migration.html
driver = {
if (browserParams.name !in WebDriverHelper.SUPPORTED_BROWSERS) {
throw new TestSpecException("Unsupported browser! Supported: ${WebDriverHelper.SUPPORTED_BROWSERS}")
}
List<String> awsMandatoryParameters = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_PROJECT_ARN']
if (!awsMandatoryParameters.every { System.getenv(it) }) {
throw new RuntimeException("""When executing tests on amazonfarm, following env properties must be set: $awsMandatoryParameters
AWS_ACCESS_KEY_ID = ${System.getenv('AWS_ACCESS_KEY_ID')?'set':'not set'}
AWS_SECRET_ACCESS_KEY = ${System.getenv('AWS_SECRET_ACCESS_KEY')?'set':'not set'}
AWS_PROJECT_ARN = ${System.getenv('AWS_PROJECT_ARN')?'set':'not set'}
""")
}

String region = System.getenv('AWS_REGION') ?: 'us-west-2'
DeviceFarmClient client = DeviceFarmClient.builder()
.region(Region.of(region)).build();
CreateTestGridUrlRequest request = CreateTestGridUrlRequest.builder()
.expiresInSeconds(180)
.projectArn(System.getenv('AWS_PROJECT_ARN'))
.build();
CreateTestGridUrlResponse response = client.createTestGridUrl(request);
URL testGridUrl = new URL(response.url()) // You can now pass this URL into RemoteWebDriver.

AbstractDriverOptions options = WebDriverHelper.createOptionsFor(browserParams.name)

WebDriver webDriver = new RemoteWebDriver(testGridUrl, options)
// TODO: build a link to amazonfarm execution video
webDriver // must be the last statement in this closure!
}
}

}
16 changes: 16 additions & 0 deletions src/test/resources/cucumber.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# for all options see: io.cucumber.core.options.Constants

cucumber.publish.quiet=true
cucumber.publish.enabled=false
#allure.results.directory=build/allure-results

# Valid values are lexical, reverse, random or random:[seed].
# By default features are executed in lexical file name order
cucumber.execution.order=lexical

cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=dynamic

# 3rd party plugins:
#cucumber.plugin=io.cucumber.core.plugin.SerenityReporterParallel
#cucumber.plugin=io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm
9 changes: 9 additions & 0 deletions src/test/resources/extent.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extent.reporter.spark.start=true
#extent.reporter.spark.out=test-output/spark/index.html
extent.reporter.spark.base64imagesrc=true

screenshot.dir=test-output/
screenshot.rel.path=../

#extent.reporter.excel.start=true
#extent.reporter.excel.out=test-output/excel/report.xlsx
4 changes: 4 additions & 0 deletions src/test/resources/simplelogger.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.slf4j.simpleLogger.defaultLogLevel=info
org.slf4j.simpleLogger.showDateTime=true
org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss
org.slf4j.simpleLogger.showShortLogName=true
Binary file added src/test/resources/unit/Book1.xlsx
Binary file not shown.
1 change: 1 addition & 0 deletions src/test/resources/unit/Converter/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Files in this dir needed for testing, do not remove.
Loading

0 comments on commit c2073cc

Please sign in to comment.