HyperExecute TestNG Use Cases
This guide outlines common Java + TestNG scenarios for running tests on HyperExecute
Q: How can I ensure my tests operate with the appropriate Java version on HyperExecute?
By default, HyperExecute VMs are provisioned with Java 8. If your project requires another version (e.g., 11, 15, 18, 22), you can use the runtime feature and specify the compatible version in the hyperexecute.yaml.
YAML Example for Java 11
runtime:
  language: java
  version: "11"
Q: What is test discovery in HyperExecute, and how does it help?
Test discovery is the process of pre-identifying the tests (classes, scenarios, or feature files) to be executed.
Why Use Test Discovery?
- Selective Execution → Run only the tests you need.
 - Flexibility → Filter by file paths, tags, or custom logic.
 - Pre-Execution Preview → Know exactly which tests will run.
 
Discovery Methods
| Type | Description | Use Case | 
|---|---|---|
raw | Runs a shell command to list tests. | Simple, filename/class-based filtering. | 
automatic | Uses HyperExecute backend tools (snooper) for discovery. | Tag or scenario-based filtering. | 
Examples
Automatic Discovery (Tag-based)
testDiscovery:
  type: automatic
  mode: static
  args:
    featureFilePaths: web/src/test/resources/features
    frameWork: java
    specificTags: ["@AccountCombineSet"]
Raw Command Discovery
testDiscovery:
  type: raw
  mode: local
  command: grep 'public class' src/test/java/hyperexecute/*.java | awk '{print $3}'
Discovery Modes
- local → Runs discovery on your machine (useful for small/simple projects).
 - remote → Runs discovery on HyperExecute VM (recommended for large projects).
 
Q: How do I include/exclude tests using tags?
You can pass logical tag expressions in testDiscovery or use the ignoredTags parameter.
Example: Logical Tag Filtering
testDiscovery:
  command: .hyperexecute/snooper --targetOs=win \
           --featureFilePaths=web/src/test/resources/features \
           --frameWork=java \
           --query="@UAT2Miniregression and not @FLNAUAT2" \
  | awk '{gsub("web/", ""); print}'
  mode: static
  type: raw
Example: Ignored Tags
ignoredTags: ["@tag3", "@tag2"]
Q: How do I configure the runner command for different Cucumber versions?
| Cucumber Version | Runner Command Example | 
|---|---|
| v6 and below | mvn test -Dcucumber.options="$test" | 
| v7 and above | mvn test -Dcucumber.features="$test" | 
Q: What if my project has multiple Maven modules?
In projects with modules (web, api, mobile), discovered test paths may include the module prefix (e.g., web/), causing mismatches.
Solution : Use awk to strip module prefixes from discovered test paths.
testDiscovery:
  command: .hyperexecute/snooper --targetOs=win \
           --featureFilePaths=web/src/test/resources/features \
           --frameWork=java \
           --specificTags=@AccountCombineSet \
  | awk '{gsub("web/", ""); print}'
  mode: static
  type: raw
Q: How should I configure testng.xml when I have multiple runners?
To avoid duplicate executions:
- Use one runner class in 
testng.xml. - Comment out tags in 
@CucumberOptions. - Let HyperExecute discovery handle filtering.
 
Example: testng.xml
<suite name="Sanity Suite">
  <test name="Test">
    <classes>
      <class name="com.qt.sid.bdd.Runner.RunnerSanity.TestRunnerUK"/>
    </classes>
  </test>
</suite>
Example: @CucumberOptions
@CucumberOptions(
  features = "src/test/resources/features",
  // tags = "@Regression and not @ignore",   // Commented out
  glue = "com/qt/sid/stepdefinitions",
  plugin = {
    "pretty",
    "html:test-output/cucumber-reports/html-report.html",
    "json:test-output/cucumber-reports/json-report.json",
    "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:",
    "json:target/cucumber.json"
  },
  monochrome = true
)
Discovery YAML Example
testDiscovery:
  type: automatic
  mode: static
  args:
    featureFilePaths: src/test/resources/features/SanitySuite
    frameWork: java
    specificTags: ["@Regression"]
Q: What if my Allure reports/screenshots are too large to render on the dashboard?
Large reports may fail to render in HyperExecute dashboard. It is recommended to generate zipped Allure reports for local viewing.
YAML Example
report: true
partialReports:
  location: allure-results/webapp
  type: zip
  frameworkName: allure-zip
To view Locally
- Install Allure
 
brew install allure
- Open report
 
allure open ./pathDirectory   # Replace pathDirectory with the actual report folder.
