-
Notifications
You must be signed in to change notification settings - Fork 314
Fixed the exception view where it was showing only the last exception #836
Conversation
| } | ||
|
|
||
| public void setExceptionContext(ExceptionInfo ei, Test test) { | ||
| reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler way to fix the overall behavior is to do this:
public class ExceptionTestContextImpl {
List<ExceptionTestContext> exTestContextList;
public ExceptionTestContextImpl() {
exTestContextList = new ArrayList<>();
}
public void setExceptionContext(ExceptionInfo ei, Test test) {
Optional<ExceptionTestContext> exOptionalTestContext = exTestContextList
.stream()
.filter(x -> x.getExceptionInfo().getExceptionName().equals(ei.getExceptionName()))
.findFirst();
if (exOptionalTestContext.isPresent()) {
List<Test> testList = exOptionalTestContext.get().getTestList();
boolean b = testList
.stream()
.filter(t -> t.getID() == test.getID())
.findFirst()
.isPresent();
if (!b)
exOptionalTestContext.get().setTest(test);
}
else {
ExceptionTestContext exTestContext = new ExceptionTestContext(ei);
exTestContext.setTest(test);
exTestContextList.add(exTestContext);
}
}
public List<ExceptionTestContext> getExceptionTestContextList() {
return exTestContextList;
}
}
`Report.java
private void copyNodeAttributeInfoToAttributeContext(Test node) {
if (node.hasCategory())
node.getCategoryContext().getAll().forEach(x -> categoryContext.setAttributeContext((Category) x, node));
if (node.hasAuthor())
node.getAuthorContext().getAll().forEach(x -> authorContext.setAttributeContext((Author) x, node));
if (node.hasChildren())
node.getNodeContext().getAll().forEach(this::copyNodeAttributeInfoToAttributeContext);
if (node.hasChildren())
node.getNodeContext().getAll().forEach(x -> {
copyNodeAttributeInfoToAttributeContext(x);
//copyNodeExceptionInfoToExceptionContext(x); <- comment this line
});
}
| } | ||
|
|
||
| synchronized void addLog(Test test, Log log) { | ||
| collectRunInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove this line of code, consider for very long tests - the user will not have up-to-date information after each log.
| <td class='linked' test-id='${ test.getID() }'>${ test.hierarchicalName }</td> | ||
| <td><pre>${ exception.exceptionInfo.getStackTrace() }</pre></td> | ||
| </tr> | ||
| <#list test.getExceptionInfoList() as testException> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we require a loop here? A test shouldn't have more than 1 exception, correct?
|
Just made a new commit with the changes.. I see all exceptions now show up in the report. This code is quite similar to what's there in the professional version, hope I didn't miss anything else. |
|
Cool, so closing this PR. |
The following are the changes as part of this PR: