New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@email2vimalraj
Collaborator

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 added the bug label Mar 31, 2017

@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
            });
    }
@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.

@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

anshooarora Mar 31, 2017

Owner

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

@anshooarora

This comment has been minimized.

Show comment
Hide comment
@anshooarora

anshooarora Apr 3, 2017

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.

Owner

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

This comment has been minimized.

Show comment
Hide comment
@email2vimalraj

email2vimalraj Apr 5, 2017

Collaborator

Cool, so closing this PR.

Collaborator

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 join this conversation on GitHub. Already have an account? Sign in to comment