Skip to main content

JUnit 4

We provide you with Native integration into JUnit 4 testing framework.

Getting Started

To integrate JUnit into your test:

  1. Add manager-client.jar to your project.
  2. Add the @RunWith annotation.
  3. Add the Reporter Server URL.
  4. Create a new ManagerPublisher.
  5. Use the created instance to report tags and files.
    The listener automatically extracts as much data as possible for you.

Capabilities

  • Automatically capture the output, trace, and stacktraces and adds them to the test

  • Add attachments (PDF, HTML reports) to the test

  • Add test tags

Simple Example

import com.experitest.manager.api.ManagerPublisher;
import com.experitest.manager.client.PManager;
import com.experitest.manager.junit.ManagerTestRunner;
import org.junit.*;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;

import java.io.File;

@RunWith(ManagerTestRunner.class)
public class SimpleExampleJUnit {

static {
System.setProperty("manager.url", "localhost:9011");
System.setProperty("manager.url", "<Cloud url>:<reverse proxy port>/reporter");// in case using Reporter that configure to a single port cloud
System.setProperty("manager.accesskey", "accesskey"); // in case using Reporter that configure to a cloud
}

private ManagerPublisher managerPublisher = null;

@Rule
public TestName testName = new TestName();

@Before
public void setup() {

// Init the managerPublisher in the before section
managerPublisher = PManager.createManagerPublisher(testName.getMethodName());
}

@Test
public void simpleTest() {

// Test goes here

// Add key value tag
managerPublisher.addProperty("team", "automation");
}

@After
public void tearDown() {

// Add custom report folder
managerPublisher.addReportFolder(new File("//path//to//file"));
}
}