Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Conversation

@email2vimalraj
Copy link
Collaborator

The following are the changes as part of this PR:

  • Fixes issue Only last exception is getting logged in Exception tab #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

}

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

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();
Copy link
Owner

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>
Copy link
Owner

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?

@anshooarora
Copy link
Owner

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

Cool, so closing this PR.

@email2vimalraj email2vimalraj deleted the bugfix-exception-view branch April 5, 2017 08:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants