Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

DynamicData Attribute Requires Public Access to Property?
kweinberg
#1 Posted : Monday, November 18, 2019 9:46:03 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/18/2019(UTC)
Posts: 2
Location: United States of America

Hello!

I've been working on configuring our code to execute our tests through NCrunch. I'm having to change several private members of my classes to be public in order for some tests to work. These tests work properly when executed through Visual Studio, but not through NCrunch. Is this a bug? Is there another way around this?

For example, I have a test using the DynamicData attribute where the supplied source data name is a private property.

Code:
private static IEnumerable<object[]> TestParameters { get; } = GetTestParameters();

[DataTestMethod]
[DynamicData(nameof(TestParameters))]
public Task ExampleUnitTest(TestParams testParams)
{
	return Task.CompletedTask;
}


The error NCrunch gives is:

Quote:
Unable to resolve dynamic data source method: Test.UnitTestClassName::get_TestParameters


Making TestParameters public will fix this error.

Thanks!

Kevin
Remco
#2 Posted : Tuesday, November 19, 2019 1:13:08 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks Kevin. We weren't aware that MSTest would work with these methods when they were private. I've made a note to see if we can get this fixed.
michaelkroes
#4 Posted : Tuesday, January 7, 2020 9:41:02 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 277
Location: Netherlands

Thanks: 122 times
Was thanked: 62 time(s) in 59 post(s)
Hi Kevin,

Sorry this has taken a while to complete. This will be fixed in the next version. This should be released in the near future.
michaelkroes
#5 Posted : Sunday, January 12, 2020 7:04:58 AM(UTC)
Rank: NCrunch Developer

Groups: Registered
Joined: 9/22/2017(UTC)
Posts: 277
Location: Netherlands

Thanks: 122 times
Was thanked: 62 time(s) in 59 post(s)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.037 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download