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

Notification

Icon
Error

Losing many tests due to duplicates in test names, but not method names
abelb
#1 Posted : Monday, November 9, 2015 9:43:14 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
I have a lot of test that are semi-autogenerated, fully autogenerated and/or in some way auto-populated. I have often wondered why I have different total test counts locally with NCrunch and remotely on the test server (TeamCity with NUnit 2.6.4 test runner).

For a new project I noticed that when I write something along the following lines (I often use FsUnit, but it is the same idea):

Code:
public class TC
{
    public int Id;
    public Guid guid;
    public string name;
}

internal static TestCaseData[] CreateTestOrders
{
    get
    {
        return new[]
        {
            new TestCaseData(new TC { Id = 123, guid = new Guid("73C9B241-11C3-4DBD-9EB8-E7BDE7A2D8DD"), name = "John" })
            .SetName("123"),
            new TestCaseData(new TC { Id = 456, guid = new Guid("01020304-11C3-4DBD-9EB8-E7BDE7A2D8DD"), name = "Anton" })
            .SetName("456"),
            new TestCaseData(new TC { Id = 789, guid = new Guid("02040608-11C3-4DBD-9EB8-E7BDE7A2D8DD"), name = "Josh" })
            .SetName("789"),
            new TestCaseData(new TC { Id = 036, guid = new Guid("12131415-11C3-4DBD-9EB8-E7BDE7A2D8DD"), name = "Jonathan" })
            .SetName("036")

        };
    }
}

[Test, TestCaseSource("CreateTestOrders")]
public void TestOrderId(TC tc)
{
    Assert.AreEqual(123, tc.Id);
}

[Test, TestCaseSource("CreateTestOrders")]
public void TestOrderPersonDetails(TC tc)
{
    Assert.Contains(tc.name, new[] { "John", "Anton", "Josh" });
}


... then I end up with four tests, not eight, in NCrunch. In NUnit test runner (the local windows tool) I see the tests grouped by namespace, classname, methodname and finally testname. In NCrunch I do not have the possibility to select methodname and instead of showing duplicates, it simply throws them away.

How can I get my tests back (if at all, and if not possible, can you consider this a bug report / feature request)? For this new project I can cater for unique names, but with some other projects, they have together close to I think 50k of test cases and it is simply undoable to find and fix all cases of duplicates, if not only because auto-generation makes it non-trivial to fix.
Remco
#2 Posted : Monday, November 9, 2015 9:48:30 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi,

See here for more information about this issue - http://forum.ncrunch.net/yaf_postst1686_Sharing-test-case-source-between-tests.aspx.

Unfortunately, because of the way NUnit handles its test identification internally, there is no way for NCrunch to process tests that are structured this way without duplication issues. The only solution is to change the design of the tests - I hope the example mentioned above can help with this.
abelb
#3 Posted : Monday, November 9, 2015 11:08:06 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Thanks for pointing me to that link. Is it possible that in the past, where we had discussions that the whole tree only showed green, but the root markers of the tree summarized it as red regardless, that this was caused by tests hidden? And is it likewise possible that when I see long delays, that it may be processing some of those hidden tests?

Quote:
Unfortunately, because of the way NUnit handles its test identification internally, there is no way for NCrunch to process tests that are structured this way without duplication issues. The only solution is to change the design of the tests - I hope the example mentioned above can help with this.


That is strange, because it is precisely NUnit's own little test runner that gets it "right" and orders them per namespace/method/testname.

This brings me to a request that I think I had quite a while ago: perhaps it wouldn't be too hard, and for me it certainly adds usability, to allow creation of order queries (based on picklists, for instance). Now we are stuck with a sometimes very useful, and sometimes not so useful set of predefined ordering sets. I remember that in the past, esp. for NCrunch, I redesigned the organization of my tests to fit at least one of these particular formats.

Rest assured, apart from the occasional critique, I am still very pleased with the product, it definitely speeds up development (and sometimes totally freezes my pc or visual studio, but that's a price I am willing to pay)!
Remco
#4 Posted : Monday, November 9, 2015 11:56:35 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
abelb;7974 wrote:
Thanks for pointing me to that link. Is it possible that in the past, where we had discussions that the whole tree only showed green, but the root markers of the tree summarized it as red regardless, that this was caused by tests hidden? And is it likewise possible that when I see long delays, that it may be processing some of those hidden tests?


This is very possible. As the duplicate-test-name warning describes, having multiple tests under the same name can cause crazy things to happen. It isn't really possible for me to know what these things are, since they are heavily dependent on the behaviour of the underlying framework and the context around the duplicate naming. But basically, you'll want to avoid it .. no good can come from it.

abelb;7974 wrote:

That is strange, because it is precisely NUnit's own little test runner that gets it "right" and orders them per namespace/method/testname.


NUnit in its raw form doesn't need to deal with the same constraints as NCrunch. As NCrunch is the consumer, this does unfortunately mean making some concessions in terms of compatibility with edge cases such as this.

abelb;7974 wrote:

This brings me to a request that I think I had quite a while ago: perhaps it wouldn't be too hard, and for me it certainly adds usability, to allow creation of order queries (based on picklists, for instance). Now we are stuck with a sometimes very useful, and sometimes not so useful set of predefined ordering sets. I remember that in the past, esp. for NCrunch, I redesigned the organization of my tests to fit at least one of these particular formats.


Sorry I'm not entirely sure what you mean here - are you referring to the execution sequence of tests in NCrunch's processing queue?

abelb;7974 wrote:

Rest assured, apart from the occasional critique, I am still very pleased with the product, it definitely speeds up development (and sometimes totally freezes my pc or visual studio, but that's a price I am willing to pay)!


Glad to hear it! I'm not aware of any outstanding crash issues though. If you can find a way to reproduce any of these, I'd be happy to help investigate.
abelb
#5 Posted : Thursday, November 12, 2015 2:56:43 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Quote:
Sorry I'm not entirely sure what you mean here - are you referring to the execution sequence of tests in NCrunch's processing queue?


No, the order of execution is already close to perfect (impacted, fast, failing tests first, etc).

In the top right of the NCrunch Tests view, just to the left of Search, there's a dropdown with a limited, fixed set of ways of ordering the tests in the pane. While this is useful, I would very much like to be able to configure this somehow, create your own order for the tree.



Something that may be relatively painless to do is parameterize what you already have, where a user can reorder these parameters, something like:

{category}/{test}

or:
{fixture}/{category}/{test}

(where the "/" denotes a new tree level, and anything between the slashes are concatenated, then sorted). These examples is one that I miss, for instance, as we have everything in categories, it is useless to have it cluttered with namespace and fixture.

I'm rarely interested in namespaces, they only clutter the view (though on some projects they add value), we usually have fixture, category and testname for our ordering.

Quote:
If you can find a way to reproduce any of these, I'd be happy to help investigate.


The most difficult of sorts is the freeze of Visual Studio (window is still painted, but no response to clicking or settings focus). In some such cases I have found a hidden, modal window using Spy++ (AnkhSvn caused this). More recently, I can't find the cause but it is not yet sure which of the addins, or VS itself, is at the root cause of it.

What happens occasionally, though, is that when VS2015 crashes (or needs to be killed), it doesn't clean up its child processes. In such cases, the NCrunch Host process does not seem to detect that its own host, Visual Studio, is gone. Firing up Visual Studio again then ends up with weird unpredictable behavior (empty screens, no docked windows, or just very slow performance, NCrunch not starting). Killing the NCrunch processes by hands did **not** solve the issue, which is rather weird. A restart of Windows so far seems to be the only remedy.

This last thing is new to VS2015, I did not have that with previous versions.

I will install the latest version of NCrunch soon (I need to update the license), I currently have the latest-but-one version.
Remco
#6 Posted : Thursday, November 12, 2015 4:46:30 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
abelb;7987 wrote:

In the top right of the NCrunch Tests view, just to the left of Search, there's a dropdown with a limited, fixed set of ways of ordering the tests in the pane. While this is useful, I would very much like to be able to configure this somehow, create your own order for the tree.


Ahh, custom grouping of tests in the Tests Window. I understand now.

This is challenging to implement because of the hidden complexity in this window. Each grouping itself has some kind of representation inside the engine, so that it can deal with complex features like the hierarchical ignoring of tests. With the design as it is right now, I don't see this being implemented in the near future. You're welcome to formally request it if you like, but I thought you should know the odds first :)

abelb;7987 wrote:

The most difficult of sorts is the freeze of Visual Studio (window is still painted, but no response to clicking or settings focus). In some such cases I have found a hidden, modal window using Spy++ (AnkhSvn caused this). More recently, I can't find the cause but it is not yet sure which of the addins, or VS itself, is at the root cause of it.


The best way to identify responsibility for freezes like this is to load up a second instance of VS, and attach a debugger to the frozen instance. You can then break into the process and view the list of running threads. A UI freeze is almost always caused by the main thread being hung, so examining the stack trace for this thread can yield some useful clues.

Note that this isn't a bulletproof way to determine responsibility, as often packages can create downstream problems that make other areas of the IDE fail. But it's still something.

abelb;7987 wrote:

What happens occasionally, though, is that when VS2015 crashes (or needs to be killed), it doesn't clean up its child processes. In such cases, the NCrunch Host process does not seem to detect that its own host, Visual Studio, is gone. Firing up Visual Studio again then ends up with weird unpredictable behavior (empty screens, no docked windows, or just very slow performance, NCrunch not starting). Killing the NCrunch processes by hands did **not** solve the issue, which is rather weird. A restart of Windows so far seems to be the only remedy.


When this happens, do you see any pattern as to which NCrunch process is left behind after VS is terminated (i.e. nCrunch.Enginehost, nCrunch.TaskRunner, etc)? The processes are coded specifically to watch for the termination of their host, so it would take some fairly catastrophic for one to be left behind in this situation.

I have a hard time understanding how any kind of failure in NCrunch could create a problem that an IDE restart couldn't solve. That doesn't mean it's impossible, it just means that at the moment I see no actions I can take to help diagnose such an issue. If a windows restart corrects the issue, I have a feeling that something could be much more deeply wrong here (perhaps in the O/S itself)?
abelb
#7 Posted : Thursday, November 12, 2015 8:25:58 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 155
Location: Netherlands

Thanks: 19 times
Was thanked: 11 time(s) in 11 post(s)
Quote:
If a windows restart corrects the issue, I have a feeling that something could be much more deeply wrong here (perhaps in the O/S itself)?


Possibly. Since my primary concern is usually productivity, I cannot always try to get to the root of the issue. I do know, for a fact, that both the host process (EngineHost) and at least six or so of the task processes were still running after I killed off devenv.exe.

But let's not bother too much about it now, if it happens again and I can find a way to repro it, I'll let you know ;).

Pity that what looks trivial, isn't (the ordering drop-down). Still, if it cannot easily be made customizable, I'd like to "just" propose a view of category/tests, or category/fixture/tests, as the only current possibility with categories is categories/namespace/fixture/test which is rather cumbersome: the usual purpose of using categories is a different categorization of the tests than already offered by namespaces and fixtures. If you then still have to click through the namespace and fixture, it doesn't add anything to use categories, which is a pity if you have strongly categorized test sets.
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.067 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download