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

Notification

Icon
Error

NCrunch, MSTest & categories
rusyn
#1 Posted : Wednesday, April 2, 2014 12:50:53 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
Similar to http://forum.ncrunch.net...ith-question-marks.aspx

We have unit tests categorised based on test function, e.g. unit, integration, and so forth.
Using NCrunch 2.5.0.12, the categories are detected & visible in the NCrunch Tests window. Using an engine mode of "DoesNotHaveCategory 'Integration'", the 'integration' tests are run in any case.

The issue has been reproduced in a single project VS 2013 solution, with the following file:

Code:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NCrunch_MSTest
{
    [TestClass]
    public class Fixture
    {
        [TestMethod]
        [TestCategory("Integration")]
        public void CategorisedIntegration_ShouldNotRun()
        {
            Assert.Fail("Integration test: should not run.");
        }

        [TestMethod]
        [TestCategory("Unit")]
        public void CategorisedUnit_ShouldRun()
        {
            // NOP.
        }

        [TestMethod]
        public void Uncategorised_ShouldRun()
        {
            // NOP.
        }
    }
}


NCrunch solution file:
Code:

<SolutionConfiguration>
  <FileVersion>1</FileVersion>
  <AllowParallelTestExecution>true</AllowParallelTestExecution>
  <AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
  <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
  <FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
  <FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
  <FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
  <EngineModes>Run all tests automatically:BFRydWU=:BFRydWU=:BFRydWU=:False;Run all tests manually:BUZhbHNl:BFRydWU=:BFRydWU=:False;Run impacted tests automatically, others manually:CklzSW1wYWN0ZWQ=:BFRydWU=:BFRydWU=:False;Run pinned tests automatically, others manually:CElzUGlubmVk:BFRydWU=:BFRydWU=:True;Not categorised as "Integration":E0RvZXNOb3RIYXZlQ2F0ZWdvcnkLSW50ZWdyYXRpb24=:BFRydWU=:BFRydWU=:False</EngineModes>
  <MetricsExclusionList>
</MetricsExclusionList>
</SolutionConfiguration>


NCrunch project file:
Code:

<ProjectConfiguration>
  <CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
  <ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
  <PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
  <AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
  <AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
  <AllowCodeAnalysis>false</AllowCodeAnalysis>
  <IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
  <RunPreBuildEvents>false</RunPreBuildEvents>
  <RunPostBuildEvents>false</RunPostBuildEvents>
  <PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
  <InstrumentAssembly>true</InstrumentAssembly>
  <PreventSigningOfAssembly>false</PreventSigningOfAssembly>
  <AnalyseExecutionTimes>true</AnalyseExecutionTimes>
  <DetectStackOverflow>true</DetectStackOverflow>
  <IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
  <DefaultTestTimeout>60000</DefaultTestTimeout>
  <UseBuildConfiguration />
  <UseBuildPlatform />
  <ProxyProcessPath />
  <UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
  <MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
  <BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>


* referencing "c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll"
Remco
#2 Posted : Wednesday, April 2, 2014 8:43:28 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

Unfortunately I haven't been able to reproduce the problem here. When I created a test project along the specifications you've provided above, then enabled NCrunch, the integration test was not run automatically while the custom engine mode was selected.

Can you describe for me the steps you go through up until the test gets run? Do you make any changes to your codebase? Are you targeting the test with the 'Run all tests' button?


Cheers,

Remco
rusyn
#3 Posted : Thursday, April 3, 2014 7:54:07 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
The integration test is run after re-opening the solution (NCrunch enabled, "Not integration test" engine selected), after disabling & re-enabling NCrunch, and also swapping engine modes.

Tests are not invoked via the "Run all tests" button; the "Run tests when needed" option was selected.

I've sent through the solution (with binaries) and the workspace files via the support / contact; hopefully this helps?
Remco
#4 Posted : Thursday, April 3, 2014 9:00:10 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks for sending through the sample solution.

I've had a bit of a play with this, but I can't seem to make it behave incorrectly. I'm wondering if there may be some kind of system related variable here, or if perhaps the behaviour of NCrunch is different from what you're expecting.

Can you try the following?

- Set your selected engine mode to your new engine mode
- Close Visual Studio and/or the solution you're working in
- Delete the _NCrunch_SOLUTION directory inside your solution directory (this will clear out the NCrunch cache)
- Reopen Visual Studio, open the solution.

The correct result from this should be that the integration test stays with the blue question mark item and is identified as 'not run', where other tests in the solution will be run.
If you make changes to the file, the test should still not be run. Disabling and enabling the engine will not run the test.

The only ways the test can run from this point should be:
- If you choose to deliberately run the test via context menu option or the Tests Window
- If you choose to 'Run all tests' in the solution
- If you swap at any time to another engine mode that does not have the same filter set up

If you swap the engine mode and swap back, you'll still see the coverage for test showing, and the test will still have a result in the Tests Window. If you make a change to your codebase, the code coverage and test results will continue to show, but you won't see any tasks created for the test in the Processing Queue.

Does all of the above match the behaviour you can observe from your side?
rusyn
#5 Posted : Monday, April 7, 2014 9:06:42 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
Matches exactly!

To recap: when the "integration" test is run, its coverage should persist across subsequent test runs.

Perhaps then an issue: the failing coverage persists after restarting Visual Studio, where the coverage markers indicate the coverage is not stale.
Remco
#6 Posted : Monday, April 7, 2014 9:26:18 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
After you restart Visual Studio, do the coverage markers show with full opacity for the excluded tests? Normally they should be slightly faded to indicate the coverage is out of date.

Are you expecting the coverage to be hidden? There is a new filter setting under the engine mode that allows you to configure which tests should have their coverage shown.
rusyn
#7 Posted : Monday, April 7, 2014 2:43:35 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
The failing tests have full opacity after the restart, and after a resynchronise.

I would expect the coverage to be reset when the engines change.
I would also expect that deleting the solution cache & resynchronising would have the same effect as closing the solution, deleting the cache, and re-opening the solution.

Would you agree?
Remco
#8 Posted : Monday, April 7, 2014 9:43:39 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
The cache is basically an on-disk representation of the contents of NCrunch's memory, so deleting it from disk with the IDE open won't clear any data. As soon as you close VS, the deleted cache will be replaced with the contents of memory.

The behaviour you've described (coverage markers being reset to full opacity after IDE restart) doesn't sound according to design. There aren't many variables in this instance. Can you try the following?

1. Set your engine mode to 'Run tests manually'
2. Make a change to your code (i.e. add a space somewhere)
3. Close the IDE
4. Open the IDE, re-open the solution
5. Wait until the engine has completed its initialisation and no tasks are executing

The engine should have started in the 'Run tests manually' engine mode. Can you confirm whether the markers are showing with full opacity, or partially faded?
rusyn
#9 Posted : Tuesday, April 8, 2014 5:51:47 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
The markers are partially faded after the restart.

Changing to "Run all tests", restart IDE, change back to "Run manually" -> markers have full opacity
Remco
#10 Posted : Tuesday, April 8, 2014 6:16:33 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Right, this then describes behaviour as designed.

The tests each include a 'dirty' state that describes when a test may have been impacted by a change made to the codebase. This dirty state is persisted in NCrunch's cache information, but it is also flagged for all tests when the code is loaded after a solution is opened, as there could have been changes made to the code between VS sessions. If you set the engine mode to run all tests, then the tests will be run after the IDE is restarted, and the tests will no longer be dirty.

Does this make sense? I'm not sure if I see anything that needs to be changed in the current implementation.
rusyn
#11 Posted : Friday, April 11, 2014 11:43:28 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/2/2014(UTC)
Posts: 6
Location: South Africa

Was thanked: 1 time(s) in 1 post(s)
Sounds good; thanks for the support!
1 user thanked rusyn for this useful post.
Remco on 4/11/2014(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.076 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download