chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I setup a very simple project that tests 2 dummy methods. I am able to run the unit test through NCover (console or Explorer) when I specify the unit tested as NUnit and get a coverage file back. However, as soon as I specify TMockRunner to run, I get no coverage file back. I get lots of errrors running the NUnit command line obviously when running my real tests. Please advise.

NCover - NUnit settings:
<xml>
<ProfilerSettings>
  <CommandLineExe>C:Program FilesNUnit 2.4.8in
unit-console.exe</CommandLineExe>
  <CommandLineArgs>"C:Documents and SettingskriskMy DocumentsVisual Studio 2008ProofsTestWebApplication1inDebugTestWebApplication1.dll" /noshadow /include=UnitTest</CommandLineArgs>
  <WorkingDirectory>C:Program FilesNUnit 2.4.8in</WorkingDirectory>
  <CoverageXml>Coverage.Xml</CoverageXml>
  <XmlFormat>Xml2</XmlFormat>
  <NoLog>false</NoLog>
  <LogFile>Coverage.log</LogFile>
  <VerboseLog>true</VerboseLog>
  <ProfileIIS>false</ProfileIIS>
  <RegisterForUser>true</RegisterForUser>
  <CoverageHtmlPath>CoverageReports</CoverageHtmlPath>
</ProfilerSettings>


NCover - TMockrunner settings:
<xml>
<ProfilerSettings>
  <CommandLineExe>C:Program FilesTypemockIsolator.1TMockRunner.exe</CommandLineExe>
  <CommandLineArgs>"C:Program FilesNUnit 2.4.8in
unit-console.exe" "C:Documents and SettingskriskMy DocumentsVisual Studio 2008ProofsTestWebApplication1inDebugTestWebApplication1.dll" /noshadow /include=UnitTest</CommandLineArgs>
  <WorkingDirectory>C:Program FilesNUnit 2.4.8in</WorkingDirectory>
  <CoverageXml>Coverage.Xml</CoverageXml>
  <XmlFormat>Xml2</XmlFormat>
  <NoLog>false</NoLog>
  <LogFile>Coverage.log</LogFile>
  <VerboseLog>true</VerboseLog>
  <ProfileIIS>false</ProfileIIS>
  <RegisterForUser>true</RegisterForUser>
  <CoverageHtmlPath>CoverageReports</CoverageHtmlPath>
</ProfilerSettings>


simple website project:
namespace WebApplication1
{
    public class Dummy
    {
        public object MethodX(bool doIt)
        {
            if (doIt)
                return new object();
            else
                return null;
        }

        public void MethodY()
        {
            //don't do anything
        }
    }
}


simple test:
using NUnit.Framework;

namespace TestWebApplication1
{
    [TestFixture]
    public class Class1
    {
        [Test, Category("UnitTest")]
        public void Test_MethodX()
        {
            WebApplication1.Dummy d = new WebApplication1.Dummy();
            object x = d.MethodX(true);

            Assert.IsNotNull(x);
        }

        [Test, Category("UnitTest")]
        public void Test_MethodY()
        {
            WebApplication1.Dummy d = new WebApplication1.Dummy();
            d.MethodY();
        }
    }
}
[/code]
asked by kkilton (2.4k points)

5 Answers

0 votes
Hi Kris

You need to link the Isolator with NCover in order to run them both.
Use the the TMockrunner -link option like this
TMockrunner -link NCover


Note that if you are using NCover 2.0 the command line should be
TMockrunner -link NCover2.0


For more information see the TMockrunner usage documentation
answered by ohad (35.4k points)
0 votes
I should have added that I had tried several combinations of -link NCover2.0 - in quotes, out of quotes, quotes for each word already. Each time I get the following, or similar, error -
fatal error: invalid argument: -link NCover2.0

...

After changing the "-link NCover2.0" to be the 1st argument in the args list, I got rid of the error, but now am getting this error in the log.
(0x0000166C) **ERROR(0x80070057)** Failed to get the assembly identity from module.
(0x0000166C) **ERROR(0x80070057)** Failed to get Assembly Identity.


I tried with and without the "-target 3.5"...

<xml>
<ProfilerSettings>
  <CommandLineExe>C:Program FilesTypemockIsolator.1TMockRunner.exe </CommandLineExe>
  <CommandLineArgs>-link NCover2.0 -target 3.5 "C:Program FilesNUnit 2.4.8in
unit-console.exe" "C:Documents and SettingskriskMy DocumentsVisual Studio 2008ProofsTestWebApplication1inDebugTestWebApplication1.dll" /noshadow /include=UnitTest</CommandLineArgs>
  <WorkingDirectory>C:Program FilesNUnit 2.4.8in</WorkingDirectory>
  <CoverageXml>Coverage.Xml</CoverageXml>
  <XmlFormat>Xml2</XmlFormat>
  <NoLog>false</NoLog>
  <LogFile>Coverage.log</LogFile>
  <VerboseLog>true</VerboseLog>
  <ProfileIIS>false</ProfileIIS>
  <RegisterForUser>true</RegisterForUser>
  <CoverageHtmlPath>CoverageReports</CoverageHtmlPath>
</ProfilerSettings>
answered by kkilton (2.4k points)
0 votes
Hi Kris

Quit strange :shock:

Can you please tell me how do you run the tests? (msbuild ,NAnt etc)
Are you running on 64 bit OS?
answered by ohad (35.4k points)
0 votes
The NCover guys showed me the way to glory! Here is the working settings file.

<xml>
<ProfilerSettings>
  <CommandLineExe>C:Program FilesTypemockIsolator.1TMockRunner.exe </CommandLineExe>
  <CommandLineArgs>-link NCover2.0 -target 3.5 "C:Program FilesNUnit 2.4.8in
unit-console.exe" "C:Documents and SettingskriskMy DocumentsVisual Studio 2008ProofsTestWebApplication1inDebugTestWebApplication1.dll" /noshadow /include=UnitTest</CommandLineArgs>
  <WorkingDirectory>C:Program FilesNUnit 2.4.8in</WorkingDirectory>
  <CoverageXml>Coverage.Xml</CoverageXml>
  <XmlFormat>Xml2</XmlFormat>
  <NoLog>false</NoLog>
  <LogFile>Coverage.log</LogFile>
  <VerboseLog>true</VerboseLog>
  <ProfileIIS>false</ProfileIIS>
  <ProfileProcessModule>nunit-console.exe</ProfileProcessModule>
  <CoverageHtmlPath>CoverageReports</CoverageHtmlPath>
</ProfilerSettings>


Here is the trick...

remove...
<RegisterForUser>true</RegisterForUser>


and make sure this is also there...
<ProfileProcessModule>nunit-console.exe</ProfileProcessModule>


Note that NCover Explorer does not allow you to remove the RegisterForUser through Explorer that I can see.
answered by kkilton (2.4k points)
0 votes
Hi Kris

Glad it solved 8)
Thanks for sharing the solution with us.
answered by ohad (35.4k points)
...