Skip to content
This repository has been archived by the owner. It is now read-only.

Fixed the exception view where it was showing only the last exception #836

Closed
wants to merge 1 commit into from

Conversation

@email2vimalraj
Copy link
Collaborator

@email2vimalraj email2vimalraj commented Mar 31, 2017

The following are the changes as part of this PR:

  • Fixes issue #808
  • Now it lists down all the exceptions. Also, we were leveraging the child exception to all the parents which seems to be not required. I had removed and keeps the exception only the node which throws that
  • Refactored the exception view template to show all the stacktraces
  • Also updated the css to show the cursor as pointer when hovering on the exception list item instead of text cursor
@email2vimalraj email2vimalraj self-assigned this Mar 31, 2017
@email2vimalraj email2vimalraj requested a review from anshooarora Mar 31, 2017
@@ -16,13 +16,11 @@ public ExceptionTestContextImpl() {
}

public void setExceptionContext(ExceptionInfo ei, Test test) {
reset();

This comment has been minimized.

@anshooarora

anshooarora Mar 31, 2017
Owner

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
            });
    }
@@ -100,8 +100,6 @@ synchronized void addNode(Test node) {
}

synchronized void addLog(Test test, Log log) {
collectRunInfo();

This comment has been minimized.

@anshooarora

anshooarora Mar 31, 2017
Owner

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>

This comment has been minimized.

@anshooarora

anshooarora Mar 31, 2017
Owner

why do we require a loop here? A test shouldn't have more than 1 exception, correct?

@anshooarora
Copy link
Owner

@anshooarora anshooarora commented Apr 3, 2017

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.

@email2vimalraj
Copy link
Collaborator Author

@email2vimalraj email2vimalraj commented Apr 5, 2017

Cool, so closing this PR.

@email2vimalraj email2vimalraj deleted the bugfix-exception-view branch Apr 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants