Skip to content

Commit

Permalink
update tests for parallel runs
Browse files Browse the repository at this point in the history
  • Loading branch information
anshooarora committed Feb 3, 2020
1 parent 63495e0 commit c1eb452
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 30 deletions.
32 changes: 32 additions & 0 deletions src/test/java/com/aventstack/extentreports/ParallelClass3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.aventstack.extentreports;

import java.lang.reflect.Method;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.common.ExtentManager;
import com.aventstack.extentreports.common.ExtentTestManager;

public class ParallelClass3 extends ParallelClassesBase {

@Test
public void parallelClass1TestResultMustEqualWarning(Method method) {
ExtentTestManager.createTest(method.getName()).info("Log from threadId: " + Thread.currentThread().getId());
ExtentTestManager.getTest().warning("Log from threadId: " + Thread.currentThread().getId());
ExtentManager.getInstance().flush();

Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void parallelClass1TestResultMustEqualSkip(Method method) {
ExtentTestManager.createTest(method.getName()).skip("Log from threadId: " + Thread.currentThread().getId());
ExtentTestManager.getTest().pass("Log from threadId: " + Thread.currentThread().getId());
ExtentManager.getInstance().flush();

Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.SKIP);
}

}
32 changes: 32 additions & 0 deletions src/test/java/com/aventstack/extentreports/ParallelClass4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.aventstack.extentreports;

import java.lang.reflect.Method;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.common.ExtentManager;
import com.aventstack.extentreports.common.ExtentTestManager;

public class ParallelClass4 extends ParallelClassesBase {

@Test
public void parallelClass1TestResultMustEqualWarning(Method method) {
ExtentTestManager.createTest(method.getName()).info("Log from threadId: " + Thread.currentThread().getId());
ExtentTestManager.getTest().warning("Log from threadId: " + Thread.currentThread().getId());
ExtentManager.getInstance().flush();

Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void parallelClass1TestResultMustEqualSkip(Method method) {
ExtentTestManager.createTest(method.getName()).skip("Log from threadId: " + Thread.currentThread().getId());
ExtentTestManager.getTest().pass("Log from threadId: " + Thread.currentThread().getId());
ExtentManager.getInstance().flush();

Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.SKIP);
}

}
290 changes: 283 additions & 7 deletions src/test/java/com/aventstack/extentreports/ParallelMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,325 @@ public void beforeClass() {

@AfterClass
public void afterClass() {
ExtentManager.getInstance().flush();
ExtentTestManager.getReporter().flush();
}

@Test
public void method1(Method method) {
ExtentTestManager.createTest(method.getName()).pass("pass");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method2(Method method) {
ExtentTestManager.createTest(method.getName()).fail("fail");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method3(Method method) {
ExtentTestManager.createTest(method.getName()).error("error");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method4(Method method) {
ExtentTestManager.createTest(method.getName()).warning("warning");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method5(Method method) {
ExtentTestManager.createTest(method.getName()).info("info");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method6(Method method) {
ExtentTestManager.createTest(method.getName()).fatal("fatal");
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method7(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).pass("");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method17(Method method) {
ExtentTestManager.createTest(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method27(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method37(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method47(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method57(Method method) {
ExtentTestManager.createTest(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method67(Method method) {
ExtentTestManager.createTest(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method77(Method method) {
ExtentTestManager.createTest(method.getName());
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method1x(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method2x(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method3x(Method method) {
ExtentTestManager.createTest(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method4x(Method method) {
ExtentTestManager.createTest(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method5x(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method6x(Method method) {
ExtentTestManager.createTest(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method7x(Method method) {
ExtentTestManager.createTest(method.getName());
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method17y(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method27y(Method method) {
ExtentTestManager.createTest(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method37y(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method47y(Method method) {
ExtentTestManager.createTest(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method57y(Method method) {
ExtentTestManager.createTest(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method67y(Method method) {
ExtentTestManager.createTest(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method77y(Method method) {
ExtentTestManager.createTest(method.getName());
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method1v(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method2v(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method3v(Method method) {
ExtentTestManager.createTest(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method4v(Method method) {
ExtentTestManager.createTest(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method5v(Method method) {
ExtentTestManager.createTest(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method6v(Method method) {
ExtentTestManager.createTest(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method7v(Method method) {
ExtentTestManager.createTest(method.getName());
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method17b(Method method) {
ExtentTestManager.createTest(method.getName()).pass("pass");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method27b(Method method) {
ExtentTestManager.createTest(method.getName()).fail("fail");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FAIL);
}

@Test
public void method37b(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).error("error");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.ERROR);
}

@Test
public void method47b(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).warning("warning");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.WARNING);
}

@Test
public void method57b(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).info("info");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method67b(Method method) {
ExtentTestManager.createTest(method.getName()).createNode(method.getName()).fatal("fatal");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.FATAL);
}

@Test
public void method77g(Method method) {
ExtentTestManager.createTest(method.getName()).pass("").createNode(method.getName()).info("");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method47g(Method method) {
ExtentTestManager.createTest(method.getName()).pass("").createNode(method.getName()).info("");
ExtentTestManager.getReporter().flush();
}

@Test
public void method57g(Method method) {
ExtentTestManager.createTest(method.getName()).pass("").createNode(method.getName()).info("");
ExtentTestManager.getReporter().flush();
Assert.assertEquals(ExtentTestManager.getTest().getStatus(), Status.PASS);
}

@Test
public void method67g(Method method) {
ExtentTestManager.createTest(method.getName()).pass("").createNode(method.getName()).info("");
ExtentTestManager.getReporter().flush();
}

@Test
public void method77u(Method method) {
ExtentTestManager.createTest(method.getName()).pass("").createNode(method.getName()).info("");
ExtentTestManager.getReporter().flush();
}
}
Loading

0 comments on commit c1eb452

Please sign in to comment.