Skip to content

Commit

Permalink
fix summary bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Alena Zubrevich authored and Alena Zubrevich committed Nov 17, 2017
1 parent 5bcd6d7 commit b31ea82
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/epam/jira/testng/RetryAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.epam.jira.testng;

import com.epam.jira.JIRATestKey;
import com.epam.jira.util.JiraInfoProvider;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

Expand All @@ -24,11 +25,10 @@ int getRerunAttempts() {
public boolean retry(ITestResult result) {
Method method = result.getMethod().getConstructorOrMethod().getMethod();
JIRATestKey annotation = method.getAnnotation(JIRATestKey.class);
int maxAttempts = annotation != null && !annotation.disabled()
? annotation.retryCountIfFailed()
: MAX_DEFAULT_ATTEMPTS;
boolean hasJiraTestKey = annotation != null && !annotation.disabled();

if (counter < maxAttempts) {
if (counter < (hasJiraTestKey ? annotation.retryCountIfFailed() : MAX_DEFAULT_ATTEMPTS)) {
if (hasJiraTestKey) JiraInfoProvider.cleanFor(annotation.key());
counter++;
return true;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/epam/jira/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ public static String save(Throwable throwable) {
String message = null;
if (throwable != null) {
String filePath = String.format("stacktrace_%s.txt", LocalDateTime.now().toString().replace(":", "-"));
String exceptionMessage = throwable.getMessage();
if (exceptionMessage.contains("\n"))
exceptionMessage = exceptionMessage.substring(0, exceptionMessage.indexOf('\n'));


FileUtils.writeStackTrace(throwable, filePath);
message = "Failed due to: " + throwable.getClass().getName() + ": " + throwable.getMessage()
message = "Failed due to: " + throwable.getClass().getName() + ": " + exceptionMessage
+ ".\nFull stack trace attached as " + filePath;
}
return message;
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/epam/jira/util/JiraInfoProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.epam.jira.JIRATestKey;
import com.epam.jira.entity.Parameter;
import org.apache.commons.lang3.ObjectUtils;

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
Expand Down Expand Up @@ -93,6 +95,16 @@ public static void saveValue(String title, Object value) {
saveValue(title, value != null ? value.toString() : "null");
}

public static void cleanFor(String issueKey) {
if (jiraKeyParametersMapping.containsKey(issueKey)) {
jiraKeyParametersMapping.remove(issueKey);
}
if (jiraKeyAttachmentsMapping.containsKey(issueKey)) {
jiraKeyAttachmentsMapping.remove(issueKey);
}

}

public static List<String> getIssueAttachments(String key) {
return jiraKeyParametersMapping.containsKey(key) ? jiraKeyAttachmentsMapping.get(key) : null;
}
Expand Down
Binary file modified test-management-adapter-1.7-jar-with-dependencies.jar
Binary file not shown.

0 comments on commit b31ea82

Please sign in to comment.