From 1ddbe6100bfab992eff135b4873176428485eb60 Mon Sep 17 00:00:00 2001 From: krmahadevan Date: Tue, 23 Jan 2024 05:18:35 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20testng-t?= =?UTF-8?q?eam/testng-team.github.io@4079a163b3a663948f0257465299db99bcf27?= =?UTF-8?q?563=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- altering_suites.html | 2 +- annotation_transformers.html | 2 +- annotations.html | 2 +- ant.html | 2 +- beanshell.html | 2 +- book-toc.html | 2 +- book.html | 2 +- class_level_annotations.html | 2 +- dependencies.html | 2 +- dependency_injection.html | 2 +- documentation.html | 4 +- download.html | 2 +- eclipse.html | 2 +- execution_visualiser.html | 204 +++++++++++++++++++++++++++++++ factories.html | 2 +- first_section.html | 2 +- github.html | 2 +- gradle.html | 2 +- iconfigurable.html | 2 +- idea.html | 2 +- ignoring_tests.html | 2 +- ihookable.html | 2 +- index.html | 4 +- introduction.html | 2 +- javadocs.html | 2 +- junit_tests.html | 2 +- logging_and_results.html | 2 +- maven.html | 2 +- method_interceptors.html | 2 +- method_invocations.html | 2 +- migrating_from_junit.html | 2 +- miscellaneous.html | 2 +- parallelism_and_timeouts.html | 2 +- parameters.html | 2 +- reportng.html | 2 +- rerunning_failed_tests.html | 2 +- run_testng_via_code.html | 2 +- running_testng.html | 2 +- second_section.html | 2 +- success_fail_assert.html | 2 +- test_methods_classes_groups.html | 2 +- test_results.html | 2 +- testng_listeners.html | 4 +- testng_run_modes.html | 2 +- testng_xml.html | 2 +- welcome.html | 2 +- yaml.html | 2 +- 47 files changed, 253 insertions(+), 49 deletions(-) create mode 100644 execution_visualiser.html diff --git a/altering_suites.html b/altering_suites.html index 4278601..ff5c540 100644 --- a/altering_suites.html +++ b/altering_suites.html @@ -67,7 +67,7 @@

Altering suites (or) tests

diff --git a/annotation_transformers.html b/annotation_transformers.html index 05b1555..9120bdd 100644 --- a/annotation_transformers.html +++ b/annotation_transformers.html @@ -154,7 +154,7 @@

Via your code

diff --git a/annotations.html b/annotations.html index 2e076f2..086726c 100644 --- a/annotations.html +++ b/annotations.html @@ -264,7 +264,7 @@

Annotations

diff --git a/ant.html b/ant.html index 227abc9..86bd654 100644 --- a/ant.html +++ b/ant.html @@ -443,7 +443,7 @@

Examples

diff --git a/beanshell.html b/beanshell.html index 6b2a5c8..e31fbdb 100644 --- a/beanshell.html +++ b/beanshell.html @@ -92,7 +92,7 @@

BeanShell and advanced group se diff --git a/book-toc.html b/book-toc.html index 427274c..d7f848f 100644 --- a/book-toc.html +++ b/book-toc.html @@ -1104,7 +1104,7 @@

Appendix D Migrating from JUnit

diff --git a/book.html b/book.html index a0fc3e7..3dcc496 100644 --- a/book.html +++ b/book.html @@ -97,7 +97,7 @@

About the Author

diff --git a/class_level_annotations.html b/class_level_annotations.html index e10feb6..aeaba87 100644 --- a/class_level_annotations.html +++ b/class_level_annotations.html @@ -64,7 +64,7 @@

Class level annotations

diff --git a/dependencies.html b/dependencies.html index 756a84d..5156729 100644 --- a/dependencies.html +++ b/dependencies.html @@ -183,7 +183,7 @@

Dependencies in XML

diff --git a/dependency_injection.html b/dependency_injection.html index 80ec458..3f8f17e 100644 --- a/dependency_injection.html +++ b/dependency_injection.html @@ -371,7 +371,7 @@

Guice dependency injection

diff --git a/documentation.html b/documentation.html index 4ef37dd..5626bd7 100644 --- a/documentation.html +++ b/documentation.html @@ -2638,7 +2638,7 @@

IExecutionListener

IExecutionVisualiser

-

Documentation To be included. +

Refer here to learn more. Javadocs are available {javadocs-base-url}/org/testng/IExecutionVisualiser.html[here]

@@ -4614,7 +4614,7 @@

Logging framework integration diff --git a/download.html b/download.html index 17dcbf5..6ca838c 100644 --- a/download.html +++ b/download.html @@ -182,7 +182,7 @@

Build the TestNG Ecli diff --git a/eclipse.html b/eclipse.html index 52b4fd1..cef1019 100644 --- a/eclipse.html +++ b/eclipse.html @@ -487,7 +487,7 @@

M2E Integration

diff --git a/execution_visualiser.html b/execution_visualiser.html new file mode 100644 index 0000000..8f56ecd --- /dev/null +++ b/execution_visualiser.html @@ -0,0 +1,204 @@ + + + + + + + +Visualising Executions + + + + + + + +
+
+

Visualising Executions

+
+

TestNG allows you to visualise the test method executions via the interface IExecutionVisualiser.

+
+
+

TestNG passes metadata about the current execution state in dot representation.

+
+
+

Color coding is done as below:

+
+
+
    +
  • +

    tests that are yet to run are colored in yellow.

    +
  • +
  • +

    tests that are currently running are colored in green.

    +
  • +
  • +

    tests that have completed execution are colored in grey.

    +
  • +
+
+
+

This listener should be declared, as explained in the section about TestNG listeners.

+
+
+

Let’s a sample.

+
+
+

Setup

+
+
    +
  • +

    Follow the instructions detailed in graphviz website to install graphviz. This binary will help us convert the dot format into png files.

    +
  • +
  • +

    Add a dependency to a library such as gifencoder so that we can convert a bunch of png files into a gif file.

    +
  • +
+
+
+
+
<dependency>
+    <groupId>com.squareup</groupId>
+    <artifactId>gifencoder</artifactId>
+    <version>0.10.1</version>
+</dependency>
+
+
+
+
+

Code sample

+
+

Here’s how a sample implementation could look like:

+
+
+
+
import com.squareup.gifencoder.FloydSteinbergDitherer;
+import com.squareup.gifencoder.GifEncoder;
+import com.squareup.gifencoder.ImageOptions;
+import org.testng.IExecutionVisualiser;
+import org.testng.IReporter;
+import org.testng.ISuite;
+import org.testng.xml.XmlSuite;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.nio.file.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class SampleVisualiser implements IExecutionVisualiser, IReporter {
+
+    private final AtomicInteger counter = new AtomicInteger(1);
+    private final Path tmpdir;
+
+    private final List<String> pngFiles = new ArrayList<>();
+
+    public SampleVisualiser() throws IOException {
+        tmpdir = Files.createTempDirectory(Paths.get("target"), "dot-");
+    }
+
+    @Override
+    public void consumeDotDefinition(String dotDefinition) {
+        String filePrefix = counter.getAndIncrement() + "-" + UUID.randomUUID();
+        Path input = Path.of(tmpdir.toFile().getAbsolutePath(), filePrefix + "-input.dot");
+        try {
+            Files.writeString(input, dotDefinition);
+            Path output = Path.of(tmpdir.toFile().getAbsolutePath(), filePrefix + "-output.png");
+            if (generatePngFileFromDotContent(input, output)) {
+                pngFiles.add(output.toFile().getAbsolutePath());
+            }
+        } catch (IOException | InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
+        //The GIF image will be created with file name "animation.gif"
+        File writeTo = new File(tmpdir.toFile().getAbsolutePath(), "animation.gif");
+        try (FileOutputStream outputStream = new FileOutputStream(writeTo)) {
+            ImageOptions options = new ImageOptions();
+
+            //Set 500ms between each frame
+            options.setDelay(500, TimeUnit.MILLISECONDS);
+            //Use Floyd Steinberg dithering as it yields the best quality
+            options.setDitherer(FloydSteinbergDitherer.INSTANCE);
+            GifEncoder encoder = new GifEncoder(outputStream, 1600, 1200, 0);
+            for (String pngFile : pngFiles) {
+                encoder.addImage(convertImageToArray(new File(pngFile)), options);
+            }
+            encoder.finishEncoding();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        System.err.println("The gif has been generated in :" + writeTo.getAbsolutePath());
+    }
+
+    private int[][] convertImageToArray(File file) throws IOException {
+        BufferedImage bufferedImage = ImageIO.read(file);
+        int[][] rgbArray = new int[bufferedImage.getHeight()][bufferedImage.getWidth()];
+        for (int i = 0; i < bufferedImage.getHeight(); i++) {
+            for (int j = 0; j < bufferedImage.getWidth(); j++) {
+                rgbArray[i][j] = bufferedImage.getRGB(j, i);
+            }
+        }
+        return rgbArray;
+    }
+
+    private static boolean generatePngFileFromDotContent(Path input, Path output) throws IOException, InterruptedException {
+        String[] cmds = {
+                "dot",
+                "-Tpng",
+                input.toFile().getAbsolutePath(),
+                "-o",
+                output.toFile().getAbsolutePath()
+        };
+        Process process = new ProcessBuilder().command(cmds).start();
+        handleInputErrorFrom(process);
+        int exitCode = process.waitFor();
+        System.err.println("PNG file written to " + output.toFile().getAbsolutePath());
+        return exitCode == 0;
+    }
+
+    private static void handleInputErrorFrom(Process process) throws IOException {
+        processStream(process.getInputStream());
+        processStream(process.getErrorStream());
+    }
+
+    private static void processStream(InputStream stream) throws IOException {
+        if (stream == null) {
+            return;
+        }
+        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+
+        String line;
+        while ((line = reader.readLine()) != null) {
+            System.out.println(line);
+        }
+    }
+}
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/factories.html b/factories.html index e197834..be16c2f 100644 --- a/factories.html +++ b/factories.html @@ -168,7 +168,7 @@

Factories

diff --git a/first_section.html b/first_section.html index 19e438d..7e03410 100644 --- a/first_section.html +++ b/first_section.html @@ -41,7 +41,7 @@

First section

diff --git a/github.html b/github.html index 9a50969..4713cae 100644 --- a/github.html +++ b/github.html @@ -60,7 +60,7 @@

ReportNG - A reporting tool

diff --git a/gradle.html b/gradle.html index 4f57acc..e98e197 100644 --- a/gradle.html +++ b/gradle.html @@ -73,7 +73,7 @@

Specifying your Gradle build file diff --git a/iconfigurable.html b/iconfigurable.html index 7d20f85..64aa307 100644 --- a/iconfigurable.html +++ b/iconfigurable.html @@ -102,7 +102,7 @@

Overriding configuration methods

diff --git a/idea.html b/idea.html index c45241c..f51cac1 100644 --- a/idea.html +++ b/idea.html @@ -71,7 +71,7 @@

Creating a TestNG Run/Debug c diff --git a/ignoring_tests.html b/ignoring_tests.html index 3e75273..da7554a 100644 --- a/ignoring_tests.html +++ b/ignoring_tests.html @@ -87,7 +87,7 @@

Ignoring tests

diff --git a/ihookable.html b/ihookable.html index 2fe76cf..e517246 100644 --- a/ihookable.html +++ b/ihookable.html @@ -50,7 +50,7 @@

Overriding test methods

diff --git a/index.html b/index.html index 647d229..3755b95 100644 --- a/index.html +++ b/index.html @@ -3246,7 +3246,7 @@

3.17.5. IExecutionListener

3.17.6. IExecutionVisualiser

-

Documentation To be included. +

Refer here to learn more. Javadocs are available here

@@ -6869,7 +6869,7 @@

15.4. ReportNG - A reporting tool

diff --git a/introduction.html b/introduction.html index 4a2e53d..9252d29 100644 --- a/introduction.html +++ b/introduction.html @@ -87,7 +87,7 @@

Introduction

diff --git a/javadocs.html b/javadocs.html index 83f085d..6169bf5 100644 --- a/javadocs.html +++ b/javadocs.html @@ -32,7 +32,7 @@

Javadocs

diff --git a/junit_tests.html b/junit_tests.html index 49bf859..2092983 100644 --- a/junit_tests.html +++ b/junit_tests.html @@ -75,7 +75,7 @@

JUnit tests

diff --git a/logging_and_results.html b/logging_and_results.html index 63032c5..f7f56d3 100644 --- a/logging_and_results.html +++ b/logging_and_results.html @@ -448,7 +448,7 @@

TestNG Exit Codes

diff --git a/maven.html b/maven.html index ce53749..fd58110 100644 --- a/maven.html +++ b/maven.html @@ -89,7 +89,7 @@

Sample reports

diff --git a/method_interceptors.html b/method_interceptors.html index ac3ce60..09cacce 100644 --- a/method_interceptors.html +++ b/method_interceptors.html @@ -226,7 +226,7 @@

Interceptors for Data Providers

diff --git a/method_invocations.html b/method_invocations.html index 62c62d8..fc469b8 100644 --- a/method_invocations.html +++ b/method_invocations.html @@ -513,7 +513,7 @@

Listening to Suite level invocati diff --git a/migrating_from_junit.html b/migrating_from_junit.html index 173e689..e83cad3 100644 --- a/migrating_from_junit.html +++ b/migrating_from_junit.html @@ -117,7 +117,7 @@

diff --git a/miscellaneous.html b/miscellaneous.html index 3ddf46f..65898af 100644 --- a/miscellaneous.html +++ b/miscellaneous.html @@ -362,7 +362,7 @@

TESTIMONIES

diff --git a/parallelism_and_timeouts.html b/parallelism_and_timeouts.html index f5fee99..8649625 100644 --- a/parallelism_and_timeouts.html +++ b/parallelism_and_timeouts.html @@ -124,7 +124,7 @@

Parallel tests, classes and methods diff --git a/parameters.html b/parameters.html index 6e7b000..4ff69b4 100644 --- a/parameters.html +++ b/parameters.html @@ -508,7 +508,7 @@

Parameters in reports
diff --git a/reportng.html b/reportng.html index cb189b3..e70a64b 100644 --- a/reportng.html +++ b/reportng.html @@ -35,7 +35,7 @@

ReportNG - A reporting tool

diff --git a/rerunning_failed_tests.html b/rerunning_failed_tests.html index 3c9b219..1076a35 100644 --- a/rerunning_failed_tests.html +++ b/rerunning_failed_tests.html @@ -93,7 +93,7 @@

Rerunning failed tests

diff --git a/run_testng_via_code.html b/run_testng_via_code.html index 9cd25a8..b6fcb2a 100644 --- a/run_testng_via_code.html +++ b/run_testng_via_code.html @@ -89,7 +89,7 @@

Running TestNG programmatically

diff --git a/running_testng.html b/running_testng.html index ba33821..7faa32f 100644 --- a/running_testng.html +++ b/running_testng.html @@ -359,7 +359,7 @@

System properties

diff --git a/second_section.html b/second_section.html index 94d3084..58eaa72 100644 --- a/second_section.html +++ b/second_section.html @@ -58,7 +58,7 @@

inner section

diff --git a/success_fail_assert.html b/success_fail_assert.html index fe3cb2e..4bb7c3c 100644 --- a/success_fail_assert.html +++ b/success_fail_assert.html @@ -61,7 +61,7 @@

Success, failure and assert

diff --git a/test_methods_classes_groups.html b/test_methods_classes_groups.html index 23ef601..b1adafa 100644 --- a/test_methods_classes_groups.html +++ b/test_methods_classes_groups.html @@ -293,7 +293,7 @@

Partial groups

diff --git a/test_results.html b/test_results.html index 02df8a7..5b7c823 100644 --- a/test_results.html +++ b/test_results.html @@ -495,7 +495,7 @@

TestNG Exit Codes

diff --git a/testng_listeners.html b/testng_listeners.html index d8c404e..b2adecf 100644 --- a/testng_listeners.html +++ b/testng_listeners.html @@ -64,7 +64,7 @@

IExecutionListener

IExecutionVisualiser

-

Documentation To be included. +

Refer here to learn more. Javadocs are available {javadocs-base-url}/org/testng/IExecutionVisualiser.html[here]

@@ -300,7 +300,7 @@

Specifying listeners with Serv diff --git a/testng_run_modes.html b/testng_run_modes.html index cf28328..ac305d7 100644 --- a/testng_run_modes.html +++ b/testng_run_modes.html @@ -1146,7 +1146,7 @@

Running TestNG programmatically

diff --git a/testng_xml.html b/testng_xml.html index 2875ce8..41ffa4e 100644 --- a/testng_xml.html +++ b/testng_xml.html @@ -136,7 +136,7 @@

testng.xml

diff --git a/welcome.html b/welcome.html index 3d663c7..e47653b 100644 --- a/welcome.html +++ b/welcome.html @@ -259,7 +259,7 @@

License

diff --git a/yaml.html b/yaml.html index e7bf00b..45627ed 100644 --- a/yaml.html +++ b/yaml.html @@ -107,7 +107,7 @@

YAML