Nunit 2.6 Gui Showing wrong result state

Bug #973248 reported by Hitesh Bhagwat
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit V2
Fix Released
Critical
Charlie Poole

Bug Description

I was using NUnit Version 2.5.2 dll for our customised nunit test application. Then It was showing proper reusult status in TestSuiteTreeView.Like if any of the child node having failure result ,it also shows parent node as failed status (Red Cross). But when I updated NUnit version 2.6 it went wrong. Now the status of the parent node is dependent on last result recieved by TestTreeNode.
When I tried to find out the root cause of this issue ,then I comes to know in TestSuiteTreeNode class under Nunit.UiKit namespace ,there is one method CalcImageIndex.This method is changed following code .In version 2.6 it is as follow

private int CalcImageIndex()
  {
            if (this.result == null)
            {
                switch (this.test.RunState)
                {
                    case RunState.Ignored:
                        return IgnoredIndex;
                    case RunState.NotRunnable:
                        return FailureIndex;
                    default:
                        return InitIndex;
                }
            }
            else
            {
                switch (this.result.ResultState)
                {
                    case ResultState.Inconclusive:
                        return InconclusiveIndex;
                    case ResultState.Skipped:
                        return SkippedIndex;
                    case ResultState.NotRunnable:
                    case ResultState.Failure:
                    case ResultState.Error:
                    case ResultState.Cancelled:
                        return FailureIndex;
                    case ResultState.Ignored:
                        return IgnoredIndex;
                    case ResultState.Success:
                        foreach (TestSuiteTreeNode node in this.Nodes)
                            if (node.ImageIndex == IgnoredIndex)
                                return IgnoredIndex;

                        return SuccessIndex;
                    default:
                        return InitIndex;
                }
            }
  }

In Version 2.5.2 it is as follow

private int CalcImageIndex()
  {
            if (this.result == null)
            {
                switch (this.test.RunState)
                {
                    case RunState.Ignored:
                        return IgnoredIndex;
                    case RunState.NotRunnable:
                        return FailureIndex;
                    default:
                        return InitIndex;
                }
            }
            else
            {
                switch (this.result.ResultState)
                {
                    case ResultState.Inconclusive:
                        return InconclusiveIndex;
                    case ResultState.Skipped:
                        return SkippedIndex;
                    case ResultState.NotRunnable:
                    case ResultState.Failure:
                    case ResultState.Error:
                    case ResultState.Cancelled:
                        return FailureIndex;
                    case ResultState.Ignored:
                        return IgnoredIndex;
                    case ResultState.Success:
                        foreach (TestSuiteTreeNode node in this.Nodes){
                             if (node.ImageIndex == FailureIndex)
                                return FailureIndex;
                            if (node.ImageIndex == IgnoredIndex)
                                return IgnoredIndex;
                        }

                        return SuccessIndex;
                    default:
                        return InitIndex;
                }
            }
}

If you see case ResultState.Success ,you will get the differnce. Why the failure case check is removed in that case?

Related branches

Revision history for this message
Hitesh Bhagwat (hiteshbhagwat) wrote :
Changed in nunitv2:
status: New → Triaged
importance: Undecided → Critical
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunitv2:
milestone: none → 2.6.1
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Actually, both the old and the new code are wrong!

The old code is sensitive to the ordering of ignored and failed tests and will return an index based on whichever one is found first. Actually, we want failure to take precedence:

                        int resultIndex = SuccessIndex;
                        foreach (TestSuiteTreeNode node in this.Nodes){
                             if (node.ImageIndex == FailureIndex)
                                return FailureIndex;
                            if (node.ImageIndex == IgnoredIndex)
                                resultIndex = IgnoredIndex;
                        }
                        return resultIndex;

Changed in nunitv2:
status: Triaged → Fix Committed
Changed in nunitv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.