Parametered test should try to convert data type from source to parameter

Bug #601645 reported by Kenneth Xu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Fix Released
Medium
Charlie Poole
NUnit V2
Fix Released
Medium
Charlie Poole

Bug Description

This is rather a feature request. Look at below test:

[TestCase(10)] public void TestMethod(short a) { }

That looks quite valid at the first glance but it of cause failed. The right syntax is

[TestCase((short)10)] public void TestMethod(short a) { }

Same problem goes to float type and/or Values attribute.

Would it be possible for NUnit to have the TestCase and Values attributes to convert the type based on the method signature?

See http://groups.google.com/group/nunit-discuss/browse_thread/thread/22898e500f20351b/ff87c7d3169be55b?hl=en&lnk=gst&q=short+type+in+parametrized+test+%09%09%09%09#ff87c7d3169be55b

Tags: feature v2port

Related branches

tags: added: feature
Revision history for this message
Charlie Poole (charlie.poole) wrote : Re: [Bug 601645] [NEW] Parametered test should try to convert data type from source to paramter

NUnit already does conversions but it won't make conversions that
could result in
the truncation of values. So it will convert short to int but not int to short.

We could change that, but I'd like to see what other folks think, so
I'll forward
this request to the mailing list.

Charlie

On Sun, Jul 4, 2010 at 10:08 AM, Kenneth Xu <email address hidden> wrote:
> Public bug reported:
>
> This is rather a feature request. Look at below test:
>
> [TestCase(10)] public void TestMethod(short a) { }
>
> That looks quite valid at the first glance but it of cause failed. The
> right syntax is
>
> [TestCase((short)10)] public void TestMethod(short a) { }
>
> Same problem goes to float type and/or Values attribute.
>
> Would it be possible for NUnit to have the TestCase and Values
> attributes to convert the type based on the method signature?
>
> See http://groups.google.com/group/nunit-
> discuss/browse_thread/thread/22898e500f20351b/ff87c7d3169be55b?hl=en&lnk=gst&q=short+type+in+parametrized+test+%09%09%09%09#ff87c7d3169be55b
>
> ** Affects: nunitv2
>     Importance: Undecided
>         Status: New
>
>
> ** Tags: feature
>
> ** Tags added: feature
>
> --
> Parametered test should try to convert data type from source to paramter
> https://bugs.launchpad.net/bugs/601645
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
>

Changed in nunitv2:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Charlie Poole (charlie.poole)
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → Medium
Changed in nunitv2:
status: In Progress → Fix Committed
Changed in nunitv2:
milestone: none → 2.5.6
Changed in nunitv2:
status: Fix Committed → Fix Released
summary: - Parametered test should try to convert data type from source to paramter
+ Parametered test should try to convert data type from source to
+ parameter
tags: added: v2port
Changed in nunit-3.0:
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 2.9.5
status: Triaged → Fix Committed
Changed in nunit-3.0:
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

Remote bug watches

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