-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add karate structure * feat: auto open karate report * chore: open report even karate fail
- Loading branch information
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
##################################### | ||
## VARIABLES ## | ||
##################################### | ||
|
||
JAVA_VERSION=17 | ||
|
||
TARGET_ENV?=qualif | ||
|
||
##################################### | ||
## DEVELOP ## | ||
##################################### | ||
|
||
# Get ara tests secrets | ||
|
||
secrets-import: ## Import secrets from GCP | ||
@mkdir -p secrets | ||
@gcloud secrets versions access latest --secret=karate-ara-qualif-config > secrets/karate-config-qualif.js | ||
|
||
# WITH JAVA MAVEN | ||
|
||
test-karate: ## Run tests. You can specify TARGET_ENV to change tests env. | ||
@echo '-- Run tests With env: $(TARGET_ENV) --' | ||
-@mvn test -DargLine="-Dkarate.env=$(TARGET_ENV) -Dkarate.config.dir=secrets" | ||
@open file:///$$PWD/target/karate-reports/karate-summary.html | ||
|
||
|
||
##################################### | ||
## PACKAGE ## | ||
##################################### | ||
|
||
|
||
##################################### | ||
## UTILS ## | ||
##################################### | ||
|
||
get-version: ## Get project version | ||
@echo $$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml) | ||
|
||
update-version: ## Update project version. VERSION required | ||
@mvn --batch-mode release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=$(VERSION)-SNAPSHOT | ||
@mvn --batch-mode versions:set -DremoveSnapshot -DprocessAllModules | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.DEFAULT_GOAL := help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# TESTS | ||
|
||
This project is used to run test ARA. | ||
|
||
It contains: | ||
|
||
* Karate tests | ||
|
||
Run `make` to display help. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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>org.example</groupId> | ||
<artifactId>tests</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-junit5</artifactId> | ||
<version>1.1.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/java</directory> | ||
<excludes> | ||
<exclude>**/*.java</exclude> | ||
</excludes> | ||
</testResource> | ||
</testResources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import com.intuit.karate.Results; | ||
import com.intuit.karate.Runner; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestParallel { | ||
@Test | ||
void testParallel() { | ||
Results results = Runner.path("classpath:ara").tags("@sanity-check").parallel(1); | ||
assertEquals(0, results.getFailCount(), results.getErrorMessages()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Feature: Connect to home page | ||
Background: | ||
* url authBaseUrl | ||
* header Authorization = 'Basic ' + authToken | ||
* form field grant_type = 'client_credentials' | ||
* method post | ||
* status 200 | ||
* def accessToken = response.access_token | ||
@sanity-check | ||
Scenario: Access Home Page | ||
Given url araBaseUrl | ||
And header Authorization = 'Bearer ' + accessToken | ||
When method get | ||
Then status 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function fn() { | ||
karate.log('Karate config start reading...', karate.env); // get java system property 'karate.env' | ||
|
||
// don't waste time waiting for a connection or if servers don't respond within 5 seconds | ||
karate.configure('connectTimeout', 5000); | ||
karate.configure('readTimeout', 5000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | ||
<file>target/karate.log</file> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<logger name="com.intuit.karate" level="DEBUG"/> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
|
||
</configuration> |