Closed letmejustfixthat closed 4 years ago
I am unable to reproduce this..
I actually create a "meta" test for every customer environment. I added the "foobar" tag to the main test for test purpose:
public static ExtentTest testStarter(final String title, final String description, final WebDriver driver, final SeleniumTestParameter parameter) {
final String testTitle = (title != null ? title : "") + " (" + parameter.getCustomer() + ", " + parameter.getBrowser() + ")";
final String testDescription = (description != null ? description : "") + " (Browser: " + parameter.getBrowser() + ", OS: " + (parameter.getOs() != null ? parameter.getOs().toString() : "any") + ")";
final ExtentTest test = getCustomerTestReport(parameter.getCustomer()).createNode(testTitle, testDescription);
if(driver instanceof RemoteWebDriver) {
final RemoteWebDriver remote = (RemoteWebDriver) driver;
if(remote.getCapabilities() != null && remote.getCapabilities().asMap() != null) {
final Map<String, Object> caps = remote.getCapabilities().asMap();
String platform = null;
if(caps.get("platformName") != null) {
platform = caps.get("platformName").toString();
} else if(caps.get("platform") != null) {
platform = caps.get("platform").toString();
}
if(platform != null) {
test.assignCategory("platform:" + platform);
if(caps.get("platformVersion") != null) {
test.assignCategory("platformVersion:" + platform + "-" + caps.get("platformVersion"));
}
}
if(caps.get("browserName") != null) {
test.assignCategory("browserName:" + caps.get("browserName"));
if(caps.get("browserVersion") != null) {
test.assignCategory("browserVersion:" + caps.get("browserName") + "-" + caps.get("browserVersion"));
}
}
}
}
return test;
}
private static ExtentTest getCustomerTestReport(final String customer) {
if(testReports.get(customer) == null) {
testReports.put(customer, getReporter().createTest(customer).assignCategory("foobar"));
}
return testReports.get(customer);
}
Opening the HTML report everything is as expected:
Opening the Klov report the tags don't appear at all:
(tested with the fresh release 0.2.3)
/edit: Also the dashboard shows that there 0 tags
So maybe it's a problem with the KlovReporter and not the KlovServer
Another update: I just came accross this documentation: http://extentreports.com/docs/versions/4/java/klov.html
That states the Tags are a "Pro-Version" exclusive. Could that be the problem? If that is actually the problem I'd say that is at least inconsistent. Tags should be a pro feature everywhere or nowhere. Having the tags in the HTML report but not in the Klov report doesn't make sense to me. In addition the tag overview etc should not be visible at all in the klov report (Now it's just empty and therefore it seems to be a bug)
Okay, I see what the issue is.. Any tag you create in testStarter
should be updated, but not by getCustomerTestReport
. Because, see here. All test related information is saved to db when it is created. Any update afterwards is not. This is the default behavior to reduce the number of queries, but can be updated to add another update in flush
.
hi ! i also have this issue, i use: klov v 4.0.9 testNG v 6.14.3
when i create the test i assign category ,author , and device. in the klov server i don't see non of those . when i make search on author i find the the tests but i don't see an icon of author on the test. when i make search on category or device i don't find anything. my code is :
ExtentTest parent = extent.createTest(result.getTestContext().getName(), testDescription);
parent.assignCategory("AST");
parent.assignDevice("Chrome");
parent.assignAuthor("Efrat");
in the HTML report they appear as expected.
Hello
I have implemented Klov in my framework using these lines of code. I am getting every detail except Tags. Could you please guide me how to add Tags to the Klov report...
ExtentKlovReporter klov = new ExtentKlovReporter();
klov.initMongoDbConnection("localhost", 27017);
klov.initKlovServerConnection("http://localhost:85");
klov.setProjectName("API");
klov.setReportName("Build: "+String.valueOf(System.currentTimeMillis()));
extent.attachReporter(klov);
extent.flush();
Thanks
@atiyap - can you please share your code to reproduce this issue? Also please share ExtentReports and Klov version.
@anshooarora - I am using this maven dependency of ExtentReports
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
`package reporting;
import com.aventstack.extentreports.*; import com.aventstack.extentreports.reporter.ExtentHtmlReporter; import com.aventstack.extentreports.reporter.ExtentKlovReporter;
import java.io.FileNotFoundException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit;
public class ExtentReportBuilderRegular {
private List
public ExtentReportBuilderRegular(List<JSONTestResults> fullTestList, List<String> ignoreList, Path reportPath) {
this.fullTestList = fullTestList;
this.ignoreList = ignoreList;
this.setReportName(reportPath);
this.scenarioDuration = 0L;
this.totalTestSetDuration = 0L;
}
public void buildRegReport() throws FileNotFoundException {
ExtentReports extent = null;
ExtentHtmlReporter htmlReporter = null;
htmlReporter = new ExtentHtmlReporter(this.reportName);
extent = new ExtentReports();
ExtentKlovReporter klov = new ExtentKlovReporter();
// klov.setAnalysisStrategy(AnalysisStrategy.TEST);
// klov.onTestStarted(a);
// klov.loadInitializationParams("src/test/resources/config/klov.properties");
extent.attachReporter(new ExtentReporter[]{htmlReporter});
extent.setReportUsesManualConfiguration(true);
Iterator var3 = this.fullTestList.iterator();
while(var3.hasNext()) {
JSONTestResults jsTestResult = (JSONTestResults)var3.next();
this.processElements(jsTestResult.getElements(), extent, jsTestResult.getTags());
}
klov.initMongoDbConnection("localhost", 27017);
klov.initKlovServerConnection("http://localhost:85");
klov.setProjectName("PromotionAPI");
klov.setReportName("Build: "+String.valueOf(System.currentTimeMillis()));
extent.attachReporter(klov);
extent.flush();
}
private void setReportName(Path reportPath) {
this.reportName = "testauto-report.html";
this.reportName = Paths.get(reportPath.toString(), this.reportName).toString();
}
private void processElements(List<Element> testResultElements, ExtentReports extent, List<Tag> featureTags) {
int scenarioOutlineCtr = 0;
List<Tag> addedTags = null;
ExtentTest curTest = null;
Element backgroundEl = null;
Iterator var9 = testResultElements.iterator();
while(var9.hasNext()) {
Element el = (Element)var9.next();
String var11 = el.getKeyword();
byte var12 = -1;
switch(var11.hashCode()) {
case -710944848:
if (var11.equals("Scenario")) {
var12 = 1;
}
break;
case 661270862:
if (var11.equals("Background")) {
var12 = 0;
}
break;
case 1280533426:
if (var11.equals("Scenario Outline")) {
var12 = 2;
}
}
Long testStart;
switch(var12) {
case 0:
backgroundEl = el;
break;
case 1:
curTest = extent.createTest(el.getName());
testStart = curTest.getModel().getStartTime().getTime() + this.totalTestSetDuration;
if (backgroundEl != null) {
this.processSteps(curTest, backgroundEl.getSteps(), "Background", testStart);
}
this.processSteps(curTest, el.getSteps(), "Scenario", testStart);
addedTags = new ArrayList();
ExtentBuilderUtils.processTags(el.getTags(), curTest, addedTags);
ExtentBuilderUtils.processTags(featureTags, curTest, addedTags);
ExtentBuilderUtils.setTestDuration(curTest, testStart, this.scenarioDuration);
backgroundEl = null;
this.scenarioDuration = 0L;
this.stepCtr = 0;
break;
case 2:
++scenarioOutlineCtr;
String testName = el.getName() + ".DataRow " + scenarioOutlineCtr;
curTest = extent.createTest(testName);
testStart = curTest.getModel().getStartTime().getTime() + this.totalTestSetDuration;
if (backgroundEl != null) {
this.processSteps(curTest, backgroundEl.getSteps(), "Background", testStart);
}
this.processSteps(curTest, el.getSteps(), "Scenario", testStart);
addedTags = new ArrayList();
ExtentBuilderUtils.processTags(el.getTags(), curTest, addedTags);
ExtentBuilderUtils.processTags(featureTags, curTest, addedTags);
ExtentBuilderUtils.setTestDuration(curTest, testStart, this.scenarioDuration);
backgroundEl = null;
this.scenarioDuration = 0L;
this.stepCtr = 0;
}
}
}
private void processSteps(ExtentTest curNode, List<Step> steps, String subStepDesc, Long testStartTime) {
this.stepCtr = ExtentBuilderUtils.logExtentStep(curNode, Status.INFO, subStepDesc, testStartTime, (DocString)null, this.stepCtr, this.totalTestSetDuration);
Iterator var5 = steps.iterator();
while(var5.hasNext()) {
Step curStep = (Step)var5.next();
this.addStepResult(curNode, curStep, curStep.getKeyword().trim(), testStartTime);
}
}
private boolean addStepResult(ExtentTest currentExtStep, Step stepData, String keyword, Long testStartTime) {
String status = stepData.getResult().getStatus();
Long stepDuration = stepData.getResult().getDuration();
DocString docString = stepData.getDocString();
boolean stepAdded = false;
String stepText = keyword + " " + stepData.getName();
Status stepStatus = null;
if (stepDuration != null && stepDuration > 0L) {
Long durationinMs = TimeUnit.NANOSECONDS.toMillis(stepDuration);
this.scenarioDuration = this.scenarioDuration + durationinMs;
this.totalTestSetDuration = this.totalTestSetDuration + durationinMs;
}
if (!ExtentBuilderUtils.isStepInIgnoreList(this.ignoreList, stepData.getName().trim(), status)) {
stepStatus = ExtentBuilderUtils.convertToExtentStatus(status);
this.stepCtr = ExtentBuilderUtils.logExtentStep(currentExtStep, stepStatus, stepText, testStartTime, docString, this.stepCtr, this.scenarioDuration);
stepAdded = true;
}
return stepAdded;
}
} `
Sorry, this doesn't help me.. Can you share only the relevant code that help me reproduce this issue? Please only share the relevant ExtentReports code.
Please let me know.......How to add tags in the klov report. I am attaching the same results to both htmlReporter and klovReporter, for html I am getting the tags but for klov I am not getting the tags.
I have attached the screenshots.
@atiyap Please share the code that I can use to reproduce this. Just need the relevant bits that helps me understand this scenario.
@anshooarora
Per the documentation, tags feature is for Pro users only. Can you please confirm?
Sample Code:
private static ExtentHtmlReporter extentHtmlReporter;
private static ExtentReports extentReports;
private static ExtentKlovReporter extentKlovReporter;
private static ThreadLocal<ExtentTest> extentTestThreadSafe = new ThreadLocal<ExtentTest>();
public static ExtentTest getTest() {
ExtentTest extentTest = extentTestThreadSafe.get();
return extentTest;
}
public static void setTest(ExtentTest test) {
extentTestThreadSafe.set(test);
}
public static void createTest(String testCaseName) {
setTest(extentReports.createTest(testCaseName));
}
private static void startKlovReport() {
extentHtmlReporter = new ExtentHtmlReporter(
System.getProperty("user.dir") + "/target/ExtentReport.html");
extentKlovReporter = new ExtentKlovReporter();
extentKlovReporter.initMongoDbConnection("localhost");
extentKlovReporter.setProjectName("test");
extentKlovReporter.setReportName("test");
extentKlovReporter.initKlovServerConnection("http://localhost:81");
extentReports = new ExtentReports();
extentReports.attachReporter(extentHtmlReporter, extentKlovReporter);
extentReports.setAnalysisStrategy(AnalysisStrategy.TEST);
}
public static void assignGroups(ITestResult result) {
for (String group : result.getMethod().getGroups()) {
getTest().assignCategory(group);
}
}
@Test(groups ={"group1"})
public void test(){
createTest("Test case 1");
}
Klov:
HTML report:
Tags overview is a standalone view/page. By default, all tags should be displayed.
@anshooarora, Have you got any clue why the tags are not being displayed at klov dashboard after seeing the above code?
Else, please provide the working code, so I will give a try with it.
@anshooarora it looks like the assignAttribute() method is not implemented in the ExtentKlovReporter.java class. The browser does not send any requests to the klov server when accessing the tags pages. Is this feature only available in the proversions of Klov server and extent reporter?
When I assign categories to tests, they aren't visible in the klov reports. How ever, in the HTML report they appear as expected. I didn't test the devices or authors though.
Klov Version 0.2.2