Adapter does not detect multiple tests when using arrays in testcase

Bug #1207946 reported by Carole Snyder
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Test Adapter
Triaged
Wishlist
Unassigned

Bug Description

Test Explorer only shows one test, given the following method.

        [TestCase(5, new int[] { 2, 3 })]
        [TestCase(5, new int[] { 1, 2, 2 })]
        public void Class1Test(int expectedTotal, int[] vals)
        {
            var calc = new Calculator();
            int total = calc.AddNums(vals);
            Assert.AreEqual(expectedTotal, total);
        }

Changing the first int in one of the test cases causes Explorer to show two test:

        [TestCase(5, new int[] { 2, 3 })]
        [TestCase(6, new int[] { 1, 2, 2 })]
        public void Class1Test(int expectedTotal, int[] vals)
        {
            var calc = new Calculator();
            int total = calc.AddNums(vals);
            Assert.AreEqual(expectedTotal, total);
        }

Used "install-package NUnitTestAdapter.WithFramework" to install version 0.96 on Visual Studio 2012 Update 3.

NUnit gui shows two test in both of the above scenarios.

Tags: github
description: updated
Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 1207946] [NEW] Adapter does not detect multiple tests when using arrays in testcase
Download full text (3.8 KiB)

This is a subtle variation on an already known problem. Test Explorer will
not allow tests with duplicate names, although NUnit does. Any true
resolution of the issue will involve a change to Test Explorer but we can
mitigate the problem by eliminating certain cases of duplication. In this
case, NUnit generates a name similar to "Class1Test(5,<int[]>)"

You can work around the problem by applying your own name to the test via
the TestName property of the attribute.

Charlie

On Sat, Aug 3, 2013 at 12:05 AM, Carole Snyder <email address hidden>wrote:

> Public bug reported:
>
> Test Explorer only shows one test, given the following method.
>
> [TestCase(5, new int[] { 2, 3 })]
> [TestCase(5, new int[] { 1, 2, 2 })]
> public void Class1Test(int expectedTotal, int[] vals)
> {
> var calc = new Calculator();
> int total = calc.AddNums(vals);
> Assert.AreEqual(expectedTotal, total);
> }
>
> Changing the first int in one of the test cases causes Explorer to show
> two test:
>
> [TestCase(5, new int[] { 2, 3 })]
> [TestCase(6, new int[] { 1, 2, 2 })]
> public void Class1Test(int expectedTotal, int[] vals)
> {
> var calc = new Calculator();
> int total = calc.AddNums(vals);
> Assert.AreEqual(expectedTotal, total);
> }
>
> Used "install-package NUnitTestAdapter.WithFramework" to install version
> 0.96 on Visual Studio 2012 Update 3.
>
> NUnit gui shows two test in both of the above scenarios.
>
> ** Affects: nunit-vs-adapter
> Importance: Undecided
> Status: New
>
> ** Description changed:
>
> Test Explorer only shows one test, given the following method.
>
> - [TestCase(5, new int[] { 2, 3 })]
> - [TestCase(5, new int[] { 1, 2, 2 })]
> - public void Class1Test(int expectedTotal, int[] vals)
> - {
> - var calc = new Calculator();
> - int total = calc.AddNums(vals);
> - Assert.AreEqual(expectedTotal, total);
> - }
> + [TestCase(5, new int[] { 2, 3 })]
> + [TestCase(5, new int[] { 1, 2, 2 })]
> + public void Class1Test(int expectedTotal, int[] vals)
> + {
> + var calc = new Calculator();
> + int total = calc.AddNums(vals);
> + Assert.AreEqual(expectedTotal, total);
> + }
>
> + Changing the first int in one of the test cases causes Explorer to show
> + two test:
>
> - Changing the first int in one of the test cases causes Explorer to show
> two test:
> + [TestCase(5, new int[] { 2, 3 })]
> + [TestCase(6, new int[] { 1, 2, 2 })]
> + public void Class1Test(int expectedTotal, int[] vals)
> + {
> + var calc = new Calculator();
> + int total = calc.AddNums(vals);
> + Assert.AreEqual(expectedTotal, total);
> + }
>
> - [TestCase(5, new int[] { 2, 3 })]
> - [TestCase(6, new int[] { 1, 2, 2 })]
> - public void Class1Test(int expectedTotal, int[] vals)
> - {
> - var calc = new Calculator();
> - int total = calc.AddN...

Read more...

Revision history for this message
Carole Snyder (carolersnyder) wrote :

Thanks for the tip. Good enough for me.

Revision history for this message
Terje Sandstrom (b-tfrje-j) wrote :

Just in case you didnt notice: The Test Explorer do show the results for both tests. In the result window, below the browser there are two results instead of as normal only one.

Changed in nunit-vs-adapter:
status: New → Triaged
importance: Undecided → Medium
milestone: none → 2.0
importance: Medium → Wishlist
Revision history for this message
Charlie Poole (charlie.poole) wrote :
Changed in nunit-vs-adapter:
status: Triaged → Won't Fix
milestone: 2.0 → none
Changed in nunit-vs-adapter:
status: Won't Fix → Triaged
tags: added: github
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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