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

Notification

Icon
Error

Array as datarow attribute parameter
konstantin
#1 Posted : Thursday, July 12, 2018 1:16:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/12/2018(UTC)
Posts: 2
Location: Russia

Hello,
There is problem in datarow attribute for unit test method. NCrunch can not substitute array parameter into test method.

For example:

[TestMethod]
[DataRow(new string[] { "0" }, false)]
[DataRow(new string[] { "0", "0", "0" }, false)]
[DataRow(new string[] { "0.0001" }, true)]
[DataRow(new string[] { "0", "5" }, true)]
[DataRow(new string[] { "0", "0.0001" }, true)]
[DataRow(new string[] { "0.0001", "0.0001" }, true)]
public void Test1_ExpectSuccess(string[] rateValues, bool expectedResult)
{
...
}

throw an exemption:
Type mismatch on test parameter 1 (System.String[] != System.Object[])

Best regards,
Konstantin
Remco
#2 Posted : Thursday, July 12, 2018 9:25:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,681

Thanks: 737 times
Was thanked: 944 time(s) in 899 post(s)
Hi Konstantin,

Do you experience this problem if you set your 'Framework utilisation type for MSTest' to 'DynamicAnalysis'?

DynamicAnalysis provides better support for edge cases like this one.
konstantin
#3 Posted : Friday, July 13, 2018 9:43:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/12/2018(UTC)
Posts: 2
Location: Russia

Thanks a lot, Remco. It works.
JeffKryzer
#4 Posted : Tuesday, June 11, 2019 6:46:12 PM(UTC)
Rank: Newbie

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

This appears to still be "broken" with the default installation. Any chance you could change this behavior to succeed with the Static setting? (So I don't have to tell 19 other developers to change a setting, for every test assembly.) Thanks!
Remco
#5 Posted : Wednesday, June 12, 2019 12:01:03 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,681

Thanks: 737 times
Was thanked: 944 time(s) in 899 post(s)
Hi, thanks for posting.

I'm sorry to say that right now that due to feasibility constraints we have no plans to change how this is implemented. Transferring complex types from an unloaded static/CIL domain into a runtime domain is very tricky business and is full of nasty edge cases, many of which are impossible to handle.

In the current version of the software, when you try to run a test of this structure under StaticAnalysis, you'll receive the following error message:

"Unable to transfer an Array from a statically analysed domain into a dynamic runtime domain. Please change your 'Framework utilisation type for MSTest' setting to 'UseDynamicAnalysis' to run this test."

The correct solution from your side is to change the configuration setting. Using NCrunch's configuration system, you can do this at shared solution level so that all developers on the team will automatically have the setting applied for them when they next update from your VCS.

DynamicAnalysis gives much better support for complex test metadata than StaticAnalysis, because we can discover the tests using the same structure as they will be executed. The current implementation is to enable StaticAnalysis by default (for performance reasons), then provide errors and warnings to encourage moving to DynamicAnalysis for codebases that make use of the edge cases that we can't properly handle using static analysis.
JeffKryzer
#6 Posted : Wednesday, June 12, 2019 4:54:39 PM(UTC)
Rank: Newbie

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

Thank you for the detailed response. Didn't know about the shared solution configuration. Will pursue.
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.036 seconds.