Skip to content

Commit

Permalink
Fix GherkinDialect related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshooarora committed Jun 19, 2024
1 parent 42f25ca commit bb9937d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/test/java/com/aventstack/extentreports/ExtentReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
import com.aventstack.extentreports.gherkin.GherkinDialectManager;
import com.aventstack.extentreports.gherkin.model.Feature;
import com.aventstack.extentreports.model.Test;
import org.testng.annotations.BeforeMethod;

public class ExtentReportsTest {

private static final String TEST_NAME = "TEST";
private ExtentReports extent;

private ExtentReports extent() {
return new ExtentReports();
@BeforeMethod
public void beforeMethod() throws UnsupportedEncodingException {
extent = new ExtentReports();
extent.setGherkinDialect("en");
}

@org.testng.annotations.Test
public void createTestOverloadTypeNameDesc() {
ExtentTest test = extent().createTest(Feature.class, TEST_NAME, "Description");
ExtentTest test = extent.createTest(Feature.class, TEST_NAME, "Description");
Test model = test.getModel();
Assert.assertTrue(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -29,7 +34,7 @@ public void createTestOverloadTypeNameDesc() {

@org.testng.annotations.Test
public void createTestOverloadTypeName() {
ExtentTest test = extent().createTest(Feature.class, TEST_NAME);
ExtentTest test = extent.createTest(Feature.class, TEST_NAME);
Test model = test.getModel();
Assert.assertTrue(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -40,7 +45,7 @@ public void createTestOverloadTypeName() {

@org.testng.annotations.Test
public void createTestOverloadKeywordNameDesc() throws ClassNotFoundException {
ExtentTest test = extent().createTest(new GherkinKeyword("Feature"), TEST_NAME, "Description");
ExtentTest test = extent.createTest(new GherkinKeyword("Feature"), TEST_NAME, "Description");
Test model = test.getModel();
Assert.assertTrue(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -51,7 +56,7 @@ public void createTestOverloadKeywordNameDesc() throws ClassNotFoundException {

@org.testng.annotations.Test
public void createTestOverloadKeywordName() throws ClassNotFoundException {
ExtentTest test = extent().createTest(new GherkinKeyword("Feature"), TEST_NAME);
ExtentTest test = extent.createTest(new GherkinKeyword("Feature"), TEST_NAME);
Test model = test.getModel();
Assert.assertTrue(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -62,7 +67,7 @@ public void createTestOverloadKeywordName() throws ClassNotFoundException {

@org.testng.annotations.Test
public void createTestOverloadNameDesc() {
ExtentTest test = extent().createTest(TEST_NAME, "Description");
ExtentTest test = extent.createTest(TEST_NAME, "Description");
Test model = test.getModel();
Assert.assertFalse(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -73,7 +78,7 @@ public void createTestOverloadNameDesc() {

@org.testng.annotations.Test
public void createTestOverloadName() {
ExtentTest test = extent().createTest(TEST_NAME);
ExtentTest test = extent.createTest(TEST_NAME);
Test model = test.getModel();
Assert.assertFalse(model.isBDD());
Assert.assertEquals(model.getName(), TEST_NAME);
Expand All @@ -84,15 +89,13 @@ public void createTestOverloadName() {

@org.testng.annotations.Test
public void gherkinDialect() throws UnsupportedEncodingException {
ExtentReports extent = extent();
extent.setGherkinDialect("de");
Assert.assertEquals(GherkinDialectManager.getLanguage(), "de");
}

@org.testng.annotations.Test
public void addTestRunnerOutputSingle() {
String[] logs = new String[]{"Log1", "Log2"};
ExtentReports extent = extent();
Arrays.stream(logs).forEach(extent::addTestRunnerOutput);
Assert.assertEquals(extent.getReport().getLogs().size(), 2);
Arrays.stream(logs).forEach(x -> Assert.assertTrue(extent.getReport().getLogs().contains(x)));
Expand All @@ -101,7 +104,6 @@ public void addTestRunnerOutputSingle() {
@org.testng.annotations.Test
public void addTestRunnerOutputList() {
String[] logs = new String[]{"Log1", "Log2"};
ExtentReports extent = extent();
extent.addTestRunnerOutput(Arrays.asList(logs));
Assert.assertEquals(extent.getReport().getLogs().size(), 2);
Arrays.stream(logs).forEach(x -> Assert.assertTrue(extent.getReport().getLogs().contains(x)));
Expand Down

0 comments on commit bb9937d

Please sign in to comment.