← Back to team overview

nunit-core team mailing list archive

[Bug 973248] Re: Nunit 2.6 Gui Showing wrong result state

 

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

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/973248

Title:
  Nunit 2.6 Gui Showing wrong result state

Status in NUnit V2 Test Framework:
  Fix Committed

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?

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunitv2/+bug/973248/+subscriptions


References