Java Overview

Introduction

Testable has support for executing Java code programs in a globally distributed fashion.

Check out the Getting Started with Java guide for a quick introduction on how to run your test plan.

This section of the documentation goes into further detail on the various options, environment variables, etc. that we support when running a Java test.

Creating a Java Scenario

There are two ways to create a Java scenario:

  1. Create a new Test Case (Create Test button on the dashboard or Test Cases -> New… on the left nav), select Java (JUnit, TestNG) during step 2.
  2. Go to an existing test case and click on the Scenario tab. Click the New Scenario button and select Java as the scenario type.

Framework

Testable supports running a Java program via a main class (i.e. Framework = None) or running your tests using JUnit or TestNG.

Source

There are several ways to load your Java scenario onto the Testable platform.

  1. Upload Jar(s)/Zip(s): Upload any jar/zip files needed to run your code and indicate the name of the main class or a list of test classes. No compilation/build step occurs on Testable in this case.
  2. Create/Edit/Upload *.java File(s): Upload all *.java files that are required or create/edit them on our website. Note that no package structure is supported in this case. All code must be in the default package and will be compiled on the test runner at test execution time.
  3. Upload Project Source as Zip File: Upload a zip file with all source code and configuration. Code is unzipped then built and run using Maven or Gradle depending on your choice. See below for more details.
  4. Build Project from Version Control: Project is cloned from version control onto the test runner. Code is built and run using Maven or Gradle here as well. See below for more details.

Build Step

If you choose to link your Git repository or upload a source zip your code needs to be compiled and built on the test runner. We support both Gradle and Maven to do this.

Gradle Build

Testable will use Gradle to build and run your project if you choose Gradle as the build tool in your scenario. You can specify which tasks each virtual user will run; the default is gradle clean test. If your project has a gradlew file, Testable will use it to run Gradle. If not, the latest installed version of Gradle on the test runner will be used.

All scenario parameters will be available as system properties and environment variables at runtime.

Our example project is a good place to start.

build.gradle

group 'io.testable'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.13.2'
}

Maven Build

Testable will use Maven to build and run your project if you choose Maven as the build tool in your scenario. You can specify which tasks each virtual user will run; the default is mvn clean test (or mvn clean verify for Serenity). If a mvnw file is detected in your project, Testable will use it to run Maven. If not, the latest installed version of Maven on the test runner will be used.

All scenario parameters will be available as system properties and environment variables at runtime.

Our example project is a good place to start.

If you have a Maven settings.xml file, it can be automatically installed at ${user.home}/.m2/settings.xml on each test runner when it runs your tests by adding it via Org Management => Settings => Package Managers => Maven settings.xml File. It will apply to all tests run within your Organization.

Testable APIs: custom metrics, CSVs, logging, and more

The testable-java library provides Testable APIs for:

  1. Custom metrics
  2. Logging
  3. Read from CSV

All these APIs will work when run locally as well. See the testable-java README for more details.