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

Notification

Icon
Error

Test category not working with MSTest
davidb
#1 Posted : Tuesday, March 13, 2012 6:55:31 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/13/2012(UTC)
Posts: 5
Location: Quebec, Canada

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I was glad to read that test categories are now supported under version 1.38b. However it looks like the TestCategory attribute used by MSTest is not working. When I add the Category column in NCrunch Tests window the value is empty even for tests that have the <TestCategory> attribute.

Are MSTest's categories going to be supported in a future version? I wish there will be also a way to exclude tests by category in NCrunch too.

Keep up with the good job. NCruch is a wonderful product!

David
Remco
#2 Posted : Tuesday, March 13, 2012 9:48:45 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi David,

Thanks for posting! Yes, NCrunch is supposed to support this attribute, but it looks like there is a problem here.

As a workaround, you should be able to use the TestProperty attribute instead, as such:

TestProperty("Category", "MyCategory")


Cheers,

Remco
1 user thanked Remco for this useful post.
davidb on 3/19/2012(UTC)
davidb
#3 Posted : Monday, March 19, 2012 5:35:46 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/13/2012(UTC)
Posts: 5
Location: Quebec, Canada

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Thanks Remco for the quick answer. Although not ideal, the workaround works just fine.

Is the "Exclude tests by category" feature going to be part of the next release of NCrunch?

David
Remco
#4 Posted : Monday, March 19, 2012 8:40:54 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
It's already there :)

You can create a custom engine mode that will exclude tests from automatically execution by their category - https://www.ncrunch.net/document...on/concepts_engine-modes
davidb
#5 Posted : Friday, March 30, 2012 3:45:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/13/2012(UTC)
Posts: 5
Location: Quebec, Canada

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi Remco,

I experimented this morning with the Custom Engine Mode to check if I could exclude some tests based on their category. I think I found a bug with how NCrunch manage test categories in VB.NET. Let met describe the problem.

Let's say I have a test class with two test methods. If I add the category attribute (using the provided workaround) to one of the method, both methods are shown to be within the "Category1" in the NCrunch Tests window

Public Class UnitTest1

<TestMethod()>
Public Sub TestMethod1()
' TODO: Add test logic here
End Sub

<TestProperty("Category", "Category1")>
<TestMethod()>
Public Sub TestMethod2()
End Sub

End Class


The official documentation from MSDN says the TestProperty attribute is supposed to "Establishes a test specific property on a method." It should not cause the property to be propagated to all the methods of the class. When using the <TestCategory> attribute the VS Tests window correctly shows that only TestMethod2 is categorized.

I'm I doing something wrong?

DB
Remco
#6 Posted : Saturday, March 31, 2012 1:58:29 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi David,

Thanks for reporting this - it also looks like a bug. For some reason the category resolver is duplicating the categories between methods. This also seems to be the case when using the NCrunch.Framework.Category attribute, which was expected to be the workaround... My assumption at this stage is that this is a problem with NCrunch's MSTest provider.

Sorry, I'll try to arrange for a fix in the next release.


Cheers,

Remco
chillitom
#7 Posted : Sunday, April 1, 2012 5:29:21 PM(UTC)
Rank: Member

Groups: Registered
Joined: 4/1/2012(UTC)
Posts: 19

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Hi Remco,

NUnit categories are being ignored as well. Trying to exclude tests with attribute [Category("Integration")] isn't working. Doesn't matter if the attribute is on the method or class.

Otherwise I'm loving NCrunch and looking forward to next release.

T.
Remco
#8 Posted : Sunday, April 1, 2012 8:47:57 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 930 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Tom,

Thanks for reporting this. Would you be able to share a code sample for the above? I can't reproduce this problem for NUnit.


Cheers,

Remco
chillitom
#9 Posted : Monday, April 2, 2012 6:50:35 PM(UTC)
Rank: Member

Groups: Registered
Joined: 4/1/2012(UTC)
Posts: 19

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Hi Remco,

Sorry seems I was wrong, they aren't infact being run but are just being listed as "Pending, Impacted" instead of being ignored completely. Not a major issue, just means the Tests window looks a bit cluttered.

Thanks,

T.
1 user thanked chillitom for this useful post.
Remco on 4/2/2012(UTC)
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.054 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download