Skip to content

Commit

Permalink
Merge pull request #83 from zebrunner/develop
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
vdelendik authored Jun 29, 2023
2 parents 5a8e36e + 367e85c commit 3fdb257
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 43 deletions.
20 changes: 1 addition & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<carina-core.version>1.0.2</carina-core.version>
<carina-core.version>1.1.3</carina-core.version>
<guava.version>31.1-jre</guava.version>
<cucumber.testng.version>7.12.0</cucumber.testng.version>
<cucumber.java.version>7.12.0</cucumber.java.version>
Expand Down Expand Up @@ -94,29 +94,11 @@
<version>${cucumber.reporting}</version>
</dependency>

<!-- Issue: #76 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>com.zebrunner</groupId>
<artifactId>carina-core</artifactId>
<version>${carina-core.version}</version>
</dependency>

<!-- For selenim-remote-driver:
Caused by: java.lang.NoClassDefFoundError: io/netty/handler/codec/DefaultHeaders$ValueValidator
todo remove netty from carina-api (carina-proxy)
-->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>4.1.84.Final</version>
</dependency>

</dependencies>

<profiles>
Expand Down
43 changes: 20 additions & 23 deletions src/main/java/com/zebrunner/carina/cucumber/CucumberRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.zebrunner.agent.core.config.ConfigurationHolder;
import com.zebrunner.agent.core.registrar.Artifact;
import com.zebrunner.agent.testng.core.testname.TestNameResolverRegistry;
import com.zebrunner.carina.core.AbstractTest;
import com.zebrunner.carina.utils.Configuration;
import com.zebrunner.carina.utils.R;
import com.zebrunner.carina.core.config.ReportConfiguration;
import com.zebrunner.carina.cucumber.config.CucumberConfiguration;
import com.zebrunner.carina.utils.commons.SpecialKeywords;
import com.zebrunner.carina.utils.config.Configuration;
import com.zebrunner.carina.utils.report.ReportContext;

import io.cucumber.testng.FeatureWrapper;
Expand Down Expand Up @@ -83,7 +85,7 @@ public void feature(PickleWrapper pickleWrapper, FeatureWrapperCustomName featur
} else {
testName = CucumberNameResolver.prepareTestName(STR_FORMAT_TEST_FOLDER_NAME, pickleWrapper, featureWrapper.getFeatureWrapper());
}
if(R.CONFIG.getBoolean("custom_testdir_naming")) {
if (Configuration.getRequired(CucumberConfiguration.Parameter.CUSTOM_TESTDIR_NAMING, Boolean.class)) {
ReportContext.setCustomTestDirName(testName);
}
testNamesList.add(testName);
Expand Down Expand Up @@ -129,9 +131,7 @@ public void tearDownClass(ITestContext context) throws Exception {
* Generate Cucumber Report
*/
private void generateCucumberReport() {
String buildNumber = Configuration.get(Configuration.Parameter.APP_VERSION);
try {
// String RootDir = System.getProperty("user.dir");
File file = ReportContext.getBaseDir();
File reportOutputDirectory = new File(String.format("%s/%s", file, SpecialKeywords.CUCUMBER_REPORT_FOLDER));
File dir = new File("target/");
Expand All @@ -141,36 +141,33 @@ private void generateCucumberReport() {
LOGGER.info("Report json: {}", fl.getName());
list.add("target/" + fl.getName());
}
// buildNumber should be parsable Integer
buildNumber = buildNumber.replace(".", "").replace(",", "");

if (!list.isEmpty()) {
// String buildNumber = "1";
// String buildProject = "CUCUMBER";
// boolean skippedFails = true;
// boolean pendingFails = true;
// boolean undefinedFails = true;
// boolean missingFails = true;

net.masterthought.cucumber.Configuration configuration = new net.masterthought.cucumber.Configuration(reportOutputDirectory,
"Cucumber Test Results");
// configuration.setStatusFlags(skippedFails, pendingFails, undefinedFails, missingFails);
// configuration.setParallelTesting(parallelTesting);
// configuration.setJenkinsBasePath(jenkinsBasePath);
// configuration.setRunWithJenkins(runWithJenkins);
configuration.setBuildNumber(buildNumber);

Configuration.get(ReportConfiguration.Parameter.APP_VERSION)
// buildNumber should be parsable Integer
.map(appVersion -> appVersion.replace(".", "").replace(",", ""))
.ifPresent(configuration::setBuildNumber);

ReportBuilder reportBuilder = new ReportBuilder(list, configuration);
reportBuilder.generateReports();

if (!Configuration.isNull(Configuration.Parameter.CI_BUILD_URL)) {
String reportUrl = Configuration.get(Configuration.Parameter.CI_BUILD_URL);
if (reportUrl.endsWith(ZAFIRA_REPORT_CI)) {
Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, reportUrl.replace(ZAFIRA_REPORT_CI, CUCUMBER_REPORT_CI));
} else {
Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, ReportContext.getCucumberReportLink());
}
}
Configuration.get(ReportConfiguration.Parameter.CI_BUILD_URL)
.ifPresent(ciBuildURL -> {
if (ConfigurationHolder.isReportingEnabled()) {
if (ciBuildURL.endsWith(ZAFIRA_REPORT_CI)) {
Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, ciBuildURL.replace(ZAFIRA_REPORT_CI, CUCUMBER_REPORT_CI));
} else {
Artifact.attachReferenceToTestRun(CUCUMBER_REPORT_NAME, ReportConfiguration.getCucumberReportLink());
}
}
});
} else {
LOGGER.info("There are no json files for cucumber report.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.zebrunner.carina.cucumber.config;

import java.util.Optional;

import com.zebrunner.carina.utils.config.Configuration;
import com.zebrunner.carina.utils.config.IParameter;

public class CucumberConfiguration extends Configuration {

public enum Parameter implements IParameter {

/**
* Determines whether the ability to set a custom test directory (report folder) name is enabled. <b>Default: false</b>
*/
CUSTOM_TESTDIR_NAMING("custom_testdir_naming");

private final String key;

Parameter(String key) {
this.key = key;
}

public String getKey() {
return key;
}
}

@Override
public String toString() {
Optional<String> asString = asString(Parameter.values());
if (asString.isEmpty()) {
return "";
}
return "\n============= Cucumber configuration ==============\n" +
asString.get();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# determines whether the ability to set a custom test directory (report folder) name is enabled
#============ Cucumber Configuration ==============#
custom_testdir_naming=false

0 comments on commit 3fdb257

Please sign in to comment.