Failure on tests parameterized with long strings

Bug #1065462 reported by Sergey S.
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
NUnit Framework
New
Undecided
Unassigned
NUnit Test Adapter
Triaged
Low
Charlie Poole

Bug Description

[This issue is now tracked on github, separately for each project affected:
  https://github.com/nunit/nunit-framework/issues/59 (framework)
  https://github.com/nunit/nunit-gui/issues/20 (gui)
  https://github.com/nunit/nunit-vs-adapter/issues/3 (adapter)]

Having the following test

  [TestCaseSource("SignBufferSamples")]
  public void GetSignBuffer(KeyValuePair<int, string> sample) {}

the adapter fails with the following log:

------ Discover test started ------
Contents of string 'GetSignBuffer([2075, MjAxMjA5MTg0MDAuMDA3MUVVUlBlbnRlZ3l0ZXN0IGFkZHJlc3MxMzQ5MDk5NzgwNGNsYXNzaWZpZWRZVDI2NjEyMzkwNDEwMjAzMjE0M0JZVDI2NjEyMzkwNDEwMjAzMjE0M0JBQVJCREU1VzEwODExMTEyMjIyNTg4ODQ4LUVVUi0zMDMxLTAxLURPTjU4ODg0OC1VQUgtMzAzMS0wMS1ET05FVVJVU0Q1NTUxMDBDb3JudWNvcGlhIEZyZXNoIEdyb2Nlcmllc0FBUkVBTCBCQU5LIEFHLDE1LCBQQVVMSU5FTlNUUkFTU0UsV0lFU0JBREVOLEdFUk1BTllBQVJCREU1VzEwOEFBUkVBTCBCQU5LIEFHLDE1LCBQQVVMSU5FTlNUUkFTU0UsV0lFU0JBREVOLEdFUk1BTll0ZXN0IGRldGFpbHMgb2YgcGF5bWVudEZhbHNlRmFsc2UyNjY0ODQwNDQzMURvbmV0c2tUcnVlRmFsc2VUcnVlRmFsc2VUcnVl])' exceeds max of '449', string has been truncated.

Exception has been thrown by the target of an invocation.
========== Discover test finished: 3203 found (0:00:05.3175317) ==========

My test assembly is built with NUnit 2.6.0.12051. The issue is reproduced no matter which .NET framework I target (3.5, 4.0, 4.5).

Tags: github
Revision history for this message
Sergey S. (frogbot) wrote :

Updated to NUnit 2.6.1.12217 - same issue.

Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 1065462] Re: Failure on tests parameterized with long strings

Is this happening only in the adapter, or directly under NUnit as well?

Charlie

On Thu, Oct 11, 2012 at 4:06 AM, Sergey S. <email address hidden> wrote:
> Updated to NUnit 2.6.1.12217 - same issue.
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1065462
>
> Title:
> Failure on tests parameterized with long strings
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunit-vs-adapter/+bug/1065462/+subscriptions

Revision history for this message
Sergey S. (frogbot) wrote :

In the adapter only, both NUnit GUI and command line runner work fine.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

I'm guessing that the IDE has a size limit for test display names that we have to adhere to. I've sent a note to the MS dev folks to be sure.

A workaround is for you to alias the test case name, using TestCaseData.SetName().

Charlie

Revision history for this message
Charlie Poole (charlie.poole) wrote :

It turns out that VS requires the test name to be no more than 449 characters, because it is used as an index into a database by some of the data collectors. It's probably better if NUnit truncates the name itself, by using ellipses in embedded strings.

Changed in nunit-vs-adapter:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 0.93
Revision history for this message
Charlie Poole (charlie.poole) wrote :

This bug would require some change in NUnit itself. I'm removing it from the 0.93 milestone and adding NUnit to the list of projects affected.

Changed in nunit-vs-adapter:
milestone: 0.93 → none
importance: Medium → Low
Changed in nunitv2:
importance: Undecided → Low
status: New → Triaged
Changed in nunitv2:
milestone: none → 2.6.3
tags: added: nunit-issue
Revision history for this message
Mark Heath (mark-heath) wrote :

We're running into the same issue with some large XML strings as test case sources:

        public string[] LegacyXmlTestCases = new string[]
        {
            Resources.FakeEmergencyAudioItem202,
            Resources.FakeEmergencyAudioItem303,
            Resources.EmergencyEventItem202,
            Resources.EmergencyEventItem303,
        };

        [TestCaseSource("LegacyXmlTestCases")]
        public void CanImportLegacyEmergencyItems(string xml)
        {
            var imported = RecordedItemImportExportHelpers.TestImportXml(xml);
            Assert.IsTrue(RecordedItemUtils.IsEmergency(imported));
        }

Revision history for this message
Charlie Poole (charlie.poole) wrote :

It turns out that sometimes the truncation of the name results in a crash, with subsequent tests not being run.

To resolve this, release 0.94 of the adapter will skip any tests that exceed the limit. You will have to use an alternate name in order for the test to be run.

The final fix has to wait for NUnit 2.6.3, where I propose to truncate each string longer than 20 chars, adding ... at the end. I'd appreciate comments from the folks experiencing this problem.

Revision history for this message
Mark Heath (mark-heath) wrote :

Sounds like a reasonable solution to me. Personally I think that the VS Test Explorer should have special support for parameterised tests, and only populate the nodes for individual test cases when the user expands the node or runs the test (I think the NUnit GUI already does this). Sometimes we use TestCaseSource to probe various network locations for data files, and I only want the testcasesource function running if I actually choose to run that test.

Thanks for your work on NUnit. The VS test adapter has potential to be very useful for us once VS supports filtering by test category.

Changed in nunit-vs-adapter:
milestone: none → 2.0
Changed in nunitv2:
milestone: 2.6.3 → none
no longer affects: nunitv2
Revision history for this message
Charlie Poole (charlie.poole) wrote :

Moved to https://github.com/nunit/nunit-vs-adapter/issues/3 and marked Won't Fix here.

Changed in nunit-vs-adapter:
milestone: 2.0 → none
status: Triaged → Won't Fix
Changed in nunit-vs-adapter:
status: Won't Fix → Triaged
tags: added: github
removed: nunit-issue
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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