1. Using SpiraTest JUnit extension with SpiraTestTestCase inheritance model

Unlike running Selenium IDE scripts through WebDriver, You don't use the Selenium plugin for RemoteLaunch, instead you should use the JUnit plugin (see https://www.inflectra.com/SpiraTest/Downloads.aspx) that will let Selenium tests written in Java / JUnit report back to SpiraTest and then use the Command-Line plugin for RemoteLaunch to actually initiate the execution of the test scripts.

Using JUnit with SpiraTest

To have JUnit report back to SpiraTest, you simply use the JUnit listener that comes with our extension and use that in conjunction with the special @SpiraTestCase attribute on the Java class to denote which test case in SpiraTest the results should be associated with.

You can then run this JUnit from the command line using Java.exe or use an IDE such as Eclipse. If you are using Eclipse, make sure to execute as a Java application not a JUnit test, since the built-in JUnit runner for Eclipse doesn't support custom listeners (or not at time of writing)

Using RemoteLaunch to Execute

Once you have the basic JUnit setup in place reporting back to SpiraTest, you can simply use the Command-Line plugin for RemoteLaunch to kick off the JUnit test harness. All of the reporting back to SpiraTest is usually left to the JUnit test fixtures themselves.

 

2. Using modern Spira JUnit extension with Annotations and Listeners

Prerequisites

  1. SpiraTest/SpiraTeam/SpiraPlan installed and licensed.

  2. RemoteLaunch client installed on the testing machine.

  3. Java Development Kit (JDK) installed (Java 8 or higher recommended).

  4. Eclipse IDE (or IntelliJ) for test development.

  5. Selenium WebDriver JARs (client drivers).

  6. JUnit (Version 4.12+ recommended for this guide).

  7. SpiraTest JUnit Extension (Download JUnitExtension.zip from the Inflectra Add-Ons page).


Step 1: Configure the Test Project

  1. Create a new Java Project in your IDE.

  2. Add the Selenium WebDriver JARs and JUnit JARs to your project's Build Path/Classpath.

  3. Extract the JUnitExtension.zip file you downloaded.

  4. Locate the com.inflectra.spiratest.addons.junitextension.jar file inside the zip and add it to your project's Classpath.


Step 2: Write the Selenium Test (The "Modern" Way)

Unlike older versions of the extension, you do not need to extend a specific class. Instead, use standard POJOs (Plain Old Java Objects) with Annotations.

  1. Add the Configuration: Add the @SpiraTestConfiguration annotation to your class.

  2. Add the Test Case Mapping: Add the @SpiraTestCase annotation to your test methods.

Example SimpleTest.java:

Java

package com.mycompany.tests;

import org.junit.Test;
import org.junit.Assert;
import com.inflectra.spiratest.addons.junitextension.SpiraTestCase;
import com.inflectra.spiratest.addons.junitextension.SpiraTestConfiguration;

// 1. Spira Configuration (Required)
// You can use the URL/User/Pwd here, or rely on RemoteLaunch to override them at runtime.
@SpiraTestConfiguration(
    url = "https://demo.spiraservice.net/my-instance",
    login = "fredbloggs",
    password = "PleaseChange",
    projectId = 1,
    releaseId = 1 // Optional, can be -1
)
public class SimpleTest {

    // 2. Map this method to a SpiraTest Test Case ID (e.g., TC:123)
    @Test
    @SpiraTestCase(testCaseId = 123)
    public void testGoogleSearch() {
        // Your Selenium WebDriver code here
        System.out.println("Running Selenium Test for TC:123...");
        Assert.assertTrue("Title should match", true);
    }
}

Step 3: Create the Test Runner (Crucial for RemoteLaunch)

To execute this test via RemoteLaunch, we need a standard "entry point" (a main method) that runs the JUnit test and attaches the SpiraTest Listener.

The previous version of this KB failed to mention the Listener, which is required for results to be sent back to Spira.

Create a new class called TestRunner.java:

Java

package com.mycompany.tests;

import org.junit.runner.JUnitCore;
import com.inflectra.spiratest.addons.junitextension.SpiraTestListener;

public class TestRunner {

    public static void main(String[] args) {
        // 1. Create the standard JUnit runner
        JUnitCore core = new JUnitCore();

        // 2. CRITICAL: Add the SpiraTest Listener
        // This listener captures the results and sends them to Spira
        core.addListener(new SpiraTestListener());

        // 3. Run the test class(es)
        // You can pass multiple classes here
        core.run(SimpleTest.class);
    }
}

Step 4: Configure RemoteLaunch

Now that you have a runnable application, you need to tell RemoteLaunch how to execute it.

  1. Compile your project into a JAR file or ensure the .class files are available in a folder (e.g., C:\Automation\bin).

  2. Open RemoteLaunch on the client machine.

  3. Go to the Setup tab and select the CommandLine automation engine (recommended for Java). Note: You can also use the specialized "JUnit" engine if you prefer, but "CommandLine" offers the most transparency for classpath issues.

  4. In SpiraTest, create a Test Case (e.g., TC:123).

  5. In the Test Automation section of the Test Case, set the Automation Engine to "CommandLine".

  6. In the Filename field, enter the command to run your TestRunner class. It will look something like this (all on one line):

DOS

java -cp "C:\Automation\bin;C:\Automation\lib\junit.jar;C:\Automation\lib\selenium.jar;C:\Automation\lib\com.inflectra.spiratest.addons.junitextension.jar" com.mycompany.tests.TestRunner

(Tip: It is often easier to save the command above into a RunTests.bat file and simply point SpiraTest's "Filename" field to C:\Automation\RunTests.bat