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

Notification

Icon
Error

Xunit 2 quirks
Inker
#1 Posted : Saturday, May 10, 2014 12:31:45 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Hi again,

I had a random test suddenly not execute right in Ncrunch. So I investigated, and found a few more quirks.
I'm using Xunit 2 2650 (the latest)).

While investigating a found a few smalish things:

  1. DisplayName shows only characters after the 23rd characeter (yes I know it's totally weird).
    eg:
    [Fact(DisplayName = "1234567890abcdefghijklmnop")]
    shows up as "nop" and
    DisplayName = "1234567890abcdefghijklm"
    shows up as "" (empty string) while
    DisplayName = "1234567890abcdefghijkl"
    is not even discovered/displayed at all

  2. If an implicit Type conversions is needed, NCrunch crashes with "System.InvalidOperationException: Sequence contains no matching element" (for both InlineData and MemberData)
    eg: InlineData(1) but paramater is long

  3. Similar to 2, but downcasting from Derived to Base also doesn't work, this time NCrunch throws a NullReferenceException
  4. If 2 or 3 happens, the symbols in in the NCrunchTest window never recover, Tests schedule to run after the test that crashed, will remain in in Running state, and even if u run a test that works
    again manually, the symbol and text remain "running"
  5. StaticDiscovery (the default) doesn't seem to work at all for me with xunit tests, even if all I have is a simple Fact test that would need no dynamic discovery?

I have provided a full sample here http://paste2.org/8xEMDk6B
This Test is setup so that Ncrunch exhibits the described behaviour, and also the stacktrace for the two exception.

Before I forget, all tests work as expected in both VS as well as R# (though I think they both just call the xunit provided engine through either the nuget packet for VS or the plugin for R#) while AFAIK ncrunch has it's own execution engine of sorts.

Cheers
PS: none of this is urgent for me
Inker
#2 Posted : Saturday, May 10, 2014 6:14:14 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Ok, another thing, if you have custom ITraitAttributes (and ITraitDiscoverer) NCrunch crashes too (I would be fine if it couldn't resolve the Trait or whatever, but it just crashes).

An error occurred while analysing this project after it was built: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'Xunit.Sdk.ITraitDiscoverer' from assembly 'xunit.core, Version=2.0.0.0,

If I switch on "Copy reference assemblies to workspace" it just get's stuck on Analysing assembly.

A sample is provided here: http://paste2.org/GwpEj3GM

Furthermore, the Exceptions from my prev post happens when given a null value too, as well as when given a parameter of type "System.Type" (which is weird because here the types actually match).

Samples here: http://paste2.org/505ytsb9

As before, both (well all three) scenarios work fine with VS/R#.
Thanks and have a nice weekend!

Remco
#3 Posted : Saturday, May 10, 2014 11:28:09 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

Thanks for sharing these issues!

The problems you're describing are happening because of the new build of Xunit (2.0.0.2650) that was just released. v2.7 of NCrunch was integrated with Xunit v2.0.0.0, and the .2650 introduced many breaking changes across Xunit's test runner API. The changes were very extensive, so in some ways it's a miracle the integration still works at all. You did well by changing the framework utilisation type to 'DynamicAnalysis', as most people probably wouldn't have thought to try this and it is actually the only way that v2.7 can work with .2650 at all :)

There's a few options here -

- You can continue to use v2.7 with .2650 and DynamicAnalysis, although many of Xunit's features won't work correctly. Probably this is OK if you're just working with simple barebones tests
- Using Nuget, you can try downgrading to an earlier beta release of Xunit. This will align NCrunch with the test runner API and the above features should work correctly. As far as I'm aware, the .2650 build was catering mostly to changes introduced from test runner integration (i.e. Resharper), so you're unlikely to notice much degradation in functionality outside of compatibility issues with these runners.
- I can share an early build of v2.8. The changes aligning NCrunch with .2650 were performed shortly after .2650 was released, but as few people seem to be using the Xunit pre-releases, it didn't seem worth pushing everyone up to a new build of NCrunch containing little but the Xunit improvements. I can probably get you something early in the coming week if you like.


Cheers,

Remco
1 user thanked Remco for this useful post.
Inker on 5/11/2014(UTC)
Inker
#4 Posted : Sunday, May 11, 2014 2:08:39 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
I see, that explains a lot, thanks for the quick reply.

1) Using it like this is a bit of a pain, mostly due to a lot of my Tests/Theories having null as one of their BadInput parameter. I wouldn't mind if the test went red, but it aborts all other tests from running and never really recovers.
2) I assume you mean Beta 1 (2616), as that was released before NCrunch 2.7? I'll give that a try (although as you note it might break R# but with NCrunch I don't really need its runner anyway).
Edit: Hmm, tried it real quick, but that doesn't seem to do anything. Still seem to get the same results (and now VS doesn't discover my tests anymore even though I downgraded xunit.runner.visualstudio.testadapter as well). Maybe I'm doing something wrong.
3) That would be great, but use your own judgement here and don't just push one for me (aybe make it 2.7.1 instead of 2.8). But if you already have the changes done, I'd be happy to test even if you don't want to release a new official build.


Again, Thanks.
PS: I just noticed you are on the Contributors list for the Beta 2 release :-)( https://github.com/xunit...releases/tag/2.0-beta-2 )
Remco
#5 Posted : Sunday, May 11, 2014 4:25:17 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Ok - based on your feedback above (2) I think it's possible that there may be some more issues beyond just those introduced by .2650. This integration with Xunit is still very new, so it hasn't seen the same rigorous real-world testing that the other adapters have. I think it's best if we try you on a new NCrunch build and see how it behaves. I'll let you know as soon as I have the build available.
1 user thanked Remco for this useful post.
Inker on 5/11/2014(UTC)
Remco
#6 Posted : Monday, May 12, 2014 9:28:54 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

I've now packaged up the new build as promised. I also performed some extra testing around the issues you described, and found that most of them actually weren't related to the .2650 xunit build at all. I'm grateful for you taking the time to report them, as I've consequently been able to introduce a number of extra fixes in this build.

http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.8.0.1.msi
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.8.0.1.zip
http://downloads.ncrunch.net/NCrunch_VS2008_2.8.0.1.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.8.0.1.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.8.0.1.zip
http://downloads.ncrunch.net/NCrunch_VS2012_2.8.0.1.msi
http://downloads.ncrunch.net/NCrunch_VS2012_2.8.0.1.zip
http://downloads.ncrunch.net/NCrunch_VS2013_2.8.0.1.msi
http://downloads.ncrunch.net/NCrunch_VS2013_2.8.0.1.zip


Take it for a spin, and let me know how it goes!

Cheers,

Remco
1 user thanked Remco for this useful post.
Inker on 5/12/2014(UTC)
Inker
#7 Posted : Monday, May 12, 2014 10:02:24 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Wow, that was quick, didn't expect that!

Unfotunatly I don't have much time today, but I did a quick spin.
I'm happy to report that all issues except for one seem to have been resolved.

Unfortunatly the remaining issue is with null parameters (which is exactly the one I have a lot of in my real tests).

With this test:
Quote:

[Theory, InlineData(null)] // doesnt work
public void Test(string value) {}

NCrunch get's stuck in "Running" and in the it's output reports:
Quote:
[16:56:12.2865-LocalTestExecutionTask-61] ERROR (Internal): System.NullReferenceException: Object reference not set to an instance of an object.
at nCrunch.Module.XUnit2.Integration.XUnit2TestFramework.findBestMatchingMethod(ITypeInfo fixtureTypeInfo, String methodName, Object[] arguments)
at nCrunch.Module.XUnit2.Integration.XUnit2TestFramework.identifyTestCasesToRun(IList`1 testsToRun, ReflectionAssemblyInfo assemblyInfo, List`1 testCases, Dictionary`2 testCasesByTestId)
at nCrunch.Module.XUnit2.Integration.XUnit2TestFramework.<>c__DisplayClass5.<RunTests>b__4()
at nCrunch.TestExecution.TestExecutionMonitor.PerformMonitoredTestExecution(Action testExecutionAction)
at nCrunch.Module.XUnit2.Integration.XUnit2TestFramework.RunTests(TestOutput output, TestExecutionMapSet testMapSet, TestExecutionParameters parameters)
at nCrunch.TestExecution.TestRunnerThread.#=qNhvXcKVjIKPPfsI4J_1mAA==()



But as I said, everything else seems to work flawlessly (at least with the Tests I prepared earlier for ncrunch).
I didn't update the grid node yet, nor did I try to run my real solution, so this is just from the local machine against the tests I prepared earlier specifically to show the problems I described.
Cheers
Remco
#8 Posted : Monday, May 12, 2014 12:11:27 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Inker
#9 Posted : Tuesday, May 13, 2014 1:49:05 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Hi,

This fixed the null bug (as I'm sure you already know).
I'll test NCrunch again against our real solution over the next couple of days. I'll report back if I find anything else.

Cheers
1 user thanked Inker for this useful post.
Remco on 5/13/2014(UTC)
Inker
#10 Posted : Saturday, May 17, 2014 12:59:24 PM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Just wanted to let you know that I haven't found anything else. I didn't get to do a ton of work this week, but when I did, ncrunch worked fine.

So thanks, great job.

BTW: can ncrunch group parametrized tests in the test window somehow? R# does this nice thing where you have one more hierarchy below. Like this:
grouping
Remco
#11 Posted : Saturday, May 17, 2014 9:10:57 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Great, thanks for confirming this!

Unfortunately the way that data is provided from the test adapters is interpreted as a flat list of tests. This is done to try to keep coupling with the test frameworks down as much as possible, as every time the frameworks are updated, there is a risk that NCrunch will break (as you've experienced).

If the readability of parameterized tests is important for you, you could try hoisting them into a nested class inside their fixture. NCrunch will detect this and group them under a different logical fixture.
Inker
#14 Posted : Sunday, May 18, 2014 1:55:43 AM(UTC)
Rank: Member

Groups: Registered
Joined: 5/9/2014(UTC)
Posts: 17
Location: Austria

Thanks: 6 times
Was thanked: 4 time(s) in 4 post(s)
Interesting idea, but it's just a small thing I noticed while using NCrunch. Not worth the hassle/effort to to create all those subclasses.

No worries.
jmackay
#12 Posted : Friday, May 23, 2014 11:14:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/30/2012(UTC)
Posts: 4
Location: United States of America

Remco;5899 wrote:
Great, thanks for confirming this!

Unfortunately the way that data is provided from the test adapters is interpreted as a flat list of tests. This is done to try to keep coupling with the test frameworks down as much as possible, as every time the frameworks are updated, there is a risk that NCrunch will break (as you've experienced).

If the readability of parameterized tests is important for you, you could try hoisting them into a nested class inside their fixture. NCrunch will detect this and group them under a different logical fixture.


Would you be able to group them by the test name, or even use an ncrunch attribute to group them?

I too have tests that have like 10 params each so they take up quite a bit of space :)
Remco
#13 Posted : Friday, May 23, 2014 11:30:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,144

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
jmackay;5937 wrote:
Would you be able to group them by the test name, or even use an ncrunch attribute to group them?

I too have tests that have like 10 params each so they take up quite a bit of space :)


Sorry, but there isn't really much that can be done to change this :(

The Project>Fixture>Test structure was baked into NCrunch very early in its development. Because the tests are always reported under the same fixture, they get grouped together. Introducing a new grouping level inside of NCrunch is gigantic piece of work that I don't expect will ever become feasible.

The best way to handle this is still to use a different fixture (i.e. nested class) or namespace.
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.155 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download