Skip to content
Permalink
Browse files

move tests produced doc-artifacts to target (#417)

  • Loading branch information...
MykolaGolubyev committed Aug 23, 2019
1 parent 5457c95 commit 4ad3019eaed11bce8ac4567848d85dab212bab25
Showing with 108 additions and 154 deletions.
  1. +0 −6 .gitignore
  2. +1 −1 README.md
  3. +1 −1 pom.xml
  4. BIN report-crud-separated-http-calls.png
  5. +16 −0 webtau-cli/src/test/java/com/twosigma/webtau/cli/CliJavaTest.java
  6. +2 −9 webtau-core/src/main/java/com/twosigma/webtau/documentation/DocumentationArtifacts.java
  7. +13 −0 webtau-core/src/main/java/com/twosigma/webtau/documentation/DocumentationArtifactsLocation.java
  8. +5 −5 webtau-docs/webtau/UI/documentation.md
  9. +5 −0 webtau-docs/webtau/lookup-paths
  10. +1 −3 webtau-feature-testing/examples/scenarios/rest/springboot/webtau.cfg
  11. +0 −10 webtau-feature-testing/examples/scenarios/ui/byNumber.groovy
  12. +19 −4 ...e-testing/src/main/groovy/com/twosigma/webtau/featuretesting/FeaturesDocArtifactsExtractor.groovy
  13. +7 −13 ...eature-testing/src/main/groovy/com/twosigma/webtau/featuretesting/WebTauEndToEndTestRunner.groovy
  14. +2 −6 ...-feature-testing/src/test/groovy/com/twosigma/webtau/featuretesting/WebTauRestFeaturesTest.groovy
  15. +9 −29 ...au-feature-testing/src/test/groovy/com/twosigma/webtau/featuretesting/WebTauUiFeaturesTest.groovy
  16. +4 −2 webtau-groovy/src/test/groovy/com/twosigma/webtau/cfg/CLIArgsTest.groovy
  17. +0 −1 webtau-http-groovy/rest-test.json
  18. +4 −6 webtau-http-groovy/src/test/groovy/com/twosigma/webtau/http/HttpGroovyTest.groovy
  19. +16 −0 webtau-http/src/test/java/com/twosigma/webtau/http/HttpTestBase.java
  20. +0 −4 webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-crud-http-calls.json
  21. BIN webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-crud-http-calls.png
  22. +0 −22 webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-crud-separated-http-calls.json
  23. BIN webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-crud-separated-http-calls.png
  24. +0 −22 webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-http-calls.json
  25. BIN webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-http-calls.png
  26. +0 −4 webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-summary.json
  27. BIN webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-summary.png
  28. +0 −4 webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-test-summary.json
  29. BIN webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-test-summary.png
  30. +2 −1 webtau-report-testing/src/test/groovy/pages/ReportLocation.groovy
  31. +1 −1 webtau-report-testing/src/test/groovy/webtau.cfg
@@ -9,9 +9,3 @@ webtau-report-*.html
*-webtau-report.html
.webtau.cache.json
.vertx
webtau-http-groovy/doc-artifacts/*
webtau-feature-testing/doc-artifacts/*
webtau-feature-testing/examples/doc-artifacts/*
webtau-groovy/doc-artifacts/*
webtau-http/doc-artifacts/*
webtau-cli/doc-artifacts/*
@@ -30,6 +30,6 @@ scenario("search by specific query") {

## Precise Reporting

![report-image](webtau-report-testing/src/test/groovy/doc-artifacts/reports/report-http-calls.png)
![report-image](report-crud-separated-http-calls.png)

[Full Documentation](https://opensource.twosigma.com/webtau/guide/)
@@ -122,12 +122,12 @@
<module>webtau-testapp</module>
<module>webtau-config</module>
<module>webtau-feature-testing</module>
<module>webtau-report-testing</module>
<module>webtau-cli-testing</module>
<module>webtau-docs</module>
<module>webtau-maven-plugin</module>
<module>webtau-maven-plugin-test</module>
<module>webtau-maven-plugin-test-skip</module>
<module>webtau-report-testing</module>
<module>webtau-shaded</module>
<module>webtau-dist</module>
<module>webtau</module>
Binary file not shown.
@@ -18,6 +18,8 @@

import com.twosigma.webtau.documentation.DocumentationArtifactsLocation;
import com.twosigma.webtau.utils.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.nio.file.Files;
@@ -29,6 +31,20 @@
import static com.twosigma.webtau.cli.CliTestUtils.nixOnly;

public class CliJavaTest {
private static Path existingDocRoot;

@BeforeClass
public static void init() {
existingDocRoot = DocumentationArtifactsLocation.getRoot();
DocumentationArtifactsLocation.setRoot(
DocumentationArtifactsLocation.classBasedLocation(CliJavaTest.class).resolve("doc-artifacts"));
}

@AfterClass
public static void clean() {
DocumentationArtifactsLocation.setRoot(existingDocRoot);
}

@Test
public void outputOnlyValidation() {
cli.run("ls -l", (output, error) -> {
@@ -18,18 +18,11 @@

import com.twosigma.webtau.utils.FileUtils;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class DocumentationArtifacts {
public static void create(Class testClass, String artifactName, String textContent) {
try {
Path path = Paths.get(testClass.getProtectionDomain().getCodeSource().getLocation().toURI())
.resolve(artifactName);
FileUtils.writeTextContent(path, textContent);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
Path path = DocumentationArtifactsLocation.classBasedLocation(testClass).resolve(artifactName);
FileUtils.writeTextContent(path, textContent);
}
}
@@ -16,6 +16,7 @@

package com.twosigma.webtau.documentation;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicReference;
@@ -27,10 +28,22 @@ public static void setRoot(Path newRoot) {
root.set(newRoot);
}

public static Path getRoot() {
return root.get();
}

public static Path resolve(String artifactName) {
return root.get().resolve(artifactName);
}

public static Path classBasedLocation(Class<?> testClass) {
try {
return Paths.get(testClass.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

private static Path getInitialRoot() {
String property = System.getProperty("documentation.artifacts.root");
return property == null ? Paths.get("doc-artifacts") : Paths.get(property);
@@ -13,19 +13,19 @@ To capture screenshots use `browser.doc[.withAnnotations].capture`:

The result of the `capture` command is two files: actual screenshot and `annotations.json`.

:include-file: doc-artifacts/ui/search.json {title: "search.json"}
:include-file: doc-artifacts/search.json {title: "search.json"}

[Webtau](https://github.com/twosigma/webtau) documentation site is generated using [Znai](https://github.com/twosigma/znai).
[Znai](https://github.com/twosigma/znai) has `include-image` plugin that supports annotations format generated by `capture` command.

:include-image: doc-artifacts/ui/search.png {fit: true, annotationsPath: "doc-artifacts/ui/search.json"}
:include-image: doc-artifacts/search.png {fit: true, annotationsPath: "doc-artifacts/search.json"}

:include-image: doc-artifacts/ui/search.png {annotationsPath: "doc-artifacts/ui/search.json"}
:include-image: doc-artifacts/search.png {annotationsPath: "doc-artifacts/search.json"}

# Annotation Types

:include-file: doc-artifacts/snippets/doc-capture/captureBadges.groovy {title: "badges"}
:include-image: doc-artifacts/ui/search.png {annotationsPath: "doc-artifacts/ui/search.json"}
:include-image: doc-artifacts/search.png {annotationsPath: "doc-artifacts/search.json"}

:include-file: doc-artifacts/snippets/doc-capture/captureHighlightCover.groovy {title: "cover and highlight"}
:include-image: doc-artifacts/ui/search-highlight-cover.png {annotationsPath: "doc-artifacts/ui/search-highlight-cover.json"}
:include-image: doc-artifacts/search-highlight-cover.png {annotationsPath: "doc-artifacts/search-highlight-cover.json"}
@@ -5,10 +5,14 @@
../../webtau-groovy/
../../webtau-groovy/src/main/groovy
../../webtau-groovy/src/main/resources
../../webtau-groovy/target/test-classes
../../webtau-feature-testing
../../webtau-feature-testing/examples
../../webtau-feature-testing/target/classes
../../webtau-http/
../../webtau-http/target/test-classes
../../webtau-http-groovy/
../../webtau-http-groovy/target/test-classes
../../webtau-browser/src/main/java
../../webtau-browser/src/test/groovy
../../webtau-browser/src/test/resources
@@ -25,4 +29,5 @@
../../webtau-junit5-examples/src/test/groovy
../../webtau-junit5-examples/src/test/java
../../webtau-report-testing/src/test/groovy
../../webtau-report-testing/target
../target/classes
@@ -1,3 +1 @@
url = "http://localhost:8080"

docPath = "doc-artifacts"
url = "http://localhost:8080"

This file was deleted.

@@ -32,6 +32,7 @@

package com.twosigma.webtau.featuretesting

import com.twosigma.webtau.documentation.DocumentationArtifactsLocation
import com.twosigma.webtau.utils.FileUtils
import com.twosigma.webtau.utils.ResourceUtils
import com.twosigma.webtau.utils.StringUtils
@@ -58,8 +59,8 @@ class FeaturesDocArtifactsExtractor {
return StringUtils.stripIndentation(removeMarkedLines(script.substring(scopeStartIdx + 1, scopeEndIdx)))
}

static void extractCodeSnippets(String extractedPath, String inputName, Map<String, String> scenarioToOutputFile) {
def artifactsRoot = Paths.get(extractedPath)
static void extractCodeSnippets(String artifactName, String inputName, Map<String, String> scenarioToOutputFile) {
def artifactsRoot = artifactsRoot(artifactName)

def script = FileUtils.fileTextContent(Paths.get(inputName))

@@ -69,12 +70,26 @@ class FeaturesDocArtifactsExtractor {
}
}

static String extractHtml(String resourceName, String css) {
static void extractHtmlSnippets(String artifactName, String resourceName, Map<String, String> cssToOutputFile) {
def artifactsRoot = artifactsRoot(artifactName)

cssToOutputFile.each { outputFileName, css ->
extractAndSaveHtml(resourceName, css,
artifactsRoot.resolve(outputFileName))
}
}

private static Path artifactsRoot(String artifactName) {
DocumentationArtifactsLocation.classBasedLocation(FeaturesDocArtifactsExtractor).
resolve('doc-artifacts').resolve('snippets').resolve(artifactName)
}

private static String extractHtml(String resourceName, String css) {
def html = ResourceUtils.textContent(resourceName)
return Jsoup.parse(html).select(css).html().toString()
}

static void extractAndSaveHtml(String resourceName, String css, Path outputPath) {
private static void extractAndSaveHtml(String resourceName, String css, Path outputPath) {
def html = extractHtml(resourceName, css)
FileUtils.writeTextContent(outputPath, html)
}
@@ -18,21 +18,15 @@ package com.twosigma.webtau.featuretesting

import com.twosigma.webtau.cfg.WebTauConfig
import com.twosigma.webtau.cli.WebTauCliApp
import com.twosigma.webtau.console.ConsoleOutputs
import com.twosigma.webtau.console.ansi.Color
import com.twosigma.webtau.expectation.ActualPath
import com.twosigma.webtau.expectation.equality.CompareToComparator
import com.twosigma.webtau.documentation.DocumentationArtifactsLocation
import com.twosigma.webtau.http.testserver.TestServer
import com.twosigma.webtau.reporter.StepReporter
import com.twosigma.webtau.reporter.StepReporters
import com.twosigma.webtau.reporter.TestStep
import com.twosigma.webtau.runner.standalone.StandaloneTest
import com.twosigma.webtau.runner.standalone.StandaloneTestListener
import com.twosigma.webtau.runner.standalone.StandaloneTestListeners
import com.twosigma.webtau.utils.FileUtils
import com.twosigma.webtau.utils.JsonUtils

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

@@ -62,15 +56,15 @@ class WebTauEndToEndTestRunner implements StepReporter, StandaloneTestListener {
StepReporters.add(this)
StandaloneTestListeners.add(this)

def reportPath = 'examples/'
if (testFileName.endsWith('.groovy')) {
reportPath += testFileName.replace('.groovy', '-webtau-report.html')
} else {
reportPath += testFileName + '/webtau-report.html'
}
def targetClassesLocation = DocumentationArtifactsLocation.classBasedLocation(WebTauEndToEndTestRunner)
def reportPath = targetClassesLocation
.resolve(testFileName.endsWith('.groovy') ?
testFileName.replace('.groovy', '-webtau-report.html'):
testFileName + '/webtau-report.html')

try {
def args = ['--workingDir=examples', '--config=' + configFileName,
'--docPath=' + targetClassesLocation.resolve('doc-artifacts'),
'--reportPath=' + reportPath]
args.addAll(Arrays.asList(additionalArgs))
args.add(testPath.toString())
@@ -60,10 +60,8 @@ class WebTauRestFeaturesTest {

@Test
void "schema validation extract snippets"() {
def root = 'doc-artifacts/snippets/json-schema'

extractCodeSnippets(
root, 'examples/scenarios/rest/jsonSchema/validateSchema.groovy', [
'json-schema', 'examples/scenarios/rest/jsonSchema/validateSchema.groovy', [
'validateBody.groovy': 'valid schema',
'validateField.groovy': 'validate specific field',
])
@@ -86,10 +84,8 @@ class WebTauRestFeaturesTest {

@Test
void "open api extract snippets"() {
def root = 'doc-artifacts/snippets/openapi'

extractCodeSnippets(
root, 'examples/scenarios/rest/openapi/disableOpenApiValidation.groovy', [
'openapi', 'examples/scenarios/rest/openapi/disableOpenApiValidation.groovy', [
'disableAll.groovy': 'disable all validation',
'disableRequest.groovy': 'disable request validation',
'disableResponse.groovy': 'disable response validation',

0 comments on commit 4ad3019

Please sign in to comment.
You can’t perform that action at this time.