JustMock+NUnit+dotCover+TeamCity

9 posts, 1 answers
  1. Pawel Paluch
    Pawel Paluch avatar
    10 posts
    Member since:
    Mar 2010

    Posted 13 Jun 2013 Link to this post

    Hello,

    similiary to Alexander in http://www.telerik.com/community/forums/justmock/general-discussions/justmock-dotcover-teamcity-problem.aspx thread i'm trying to make satup for unit test running nunit+justMock+dotcover, and i'm facing problems similiar to Alexander's, thus i created simple test as suggested in mentioned thread:

    Assert.IsTrue(Mock.IsProfilerEnabled);


    which results in following output:
    [16:41:15][Step 6/7] NuSoft.Printer.Rs232.Tests.dll
     
    [16:41:15][NuSoft.Printer.Rs232.Tests.dll] NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted
     
    [16:41:15][NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted] Test(s) failed.   Expected: True
     
      But was:  False
     
    [16:41:15][NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted] Test(s) failed.   Expected: True
     
      But was:  False
     
       at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
     
       at NUnit.Framework.Assert.IsTrue(Boolean condition)
     
       at NuSoft.Printer.Rs232.Tests.PrinterTest.CheckProfiler() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 18
     
       at NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 24

    I followed manual http://www.telerik.com/help/justmock/integration-teamcity.html section Integrating JustMock within TeamCity using MS Test or NUnit build steps with dotCover and Profiler is linked to dotCover (the only one installed is the one bundled with TeamCity) and JUSTMOCK_INSTANCE=1 variable is present in build parameters.

    tests run in VS2012, also when configured accordingly to Integrating JustMock within TeamCity using MS Test or NUnit build steps.

    Telerik.JustMock - 2013.2.611.0
    TeamCity - 7.1.5 (build 24400)

    is there any thing that can be done in order to configure justmock to run on teamcity with nUint and dotCover?

  2. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 14 Jun 2013 Link to this post

    Hello Pawel Paluch,

    It is possible that, the JustMock profiler has been disabled (in this case Mock.IsProfilerEnabled will return "false" and so the test is expected to fail). To confirm this is not the issue and enable the profiler from a test, I would ask you to replace this test with a more appropriate one:
    [Test]
    public void ShouldTestElevatedScenario()
    {
        // Arrange
        var expected = new DateTime(2000, 12, 12);
        Mock.Arrange(() => DateTime.Now).Returns(expected);
     
        // Assert
        Assert.AreEqual(expected, DateTime.Now);
    }

    Let me know if this test is also failing inside your build process.

    Thank you for the assistance in advance.

    Regards,
    Kaloyan
    Telerik
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. DevCraft R3 2016 release webinar banner
  4. Pawel Paluch
    Pawel Paluch avatar
    10 posts
    Member since:
    Mar 2010

    Posted 21 Jun 2013 Link to this post

    Hello,

    result was "Test(s) failed. Telerik.JustMock.Core.ElevatedMockingException : Cannot mock 'System.DateTime'. The profiler must be enabled to mock, arrange or execute the specified target."
  5. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 24 Jun 2013 Link to this post

    Hello Pawel Paluch,

    This is highly unfortunate.

    Could you send us the logs from event with ID 1022 right after your build executes the JustMock tests? You can find them in the Windows Event Viewer, under Windows Logs > Application.

    Thank you for the help and the understanding.

    Regards,
    Kaloyan
    Telerik
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  6. Pawel Paluch
    Pawel Paluch avatar
    10 posts
    Member since:
    Mar 2010

    Posted 24 Jun 2013 Link to this post

    Hello,

    there are no logs with 1022 ID.
    Executed few builds with "Visual Studio (sln)" step and "NUnit" step,and nothing in application logs.
  7. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 26 Jun 2013 Link to this post

    Hello Pawel Paluch,

    This is very strange. It means that both the JustMock and the dotCover profilers are not loading into your build process.

    To help you further, I need to know if you can see any coverage results even with failed tests?

    If the coverage is also missing, I will suggest to set up your build process in a way that runs dotCover and gathers coverage information. Then, try to link both the JustMock and dotCover profilers and check if the issue will remain.

    Also, please make sure the JUSTMOCK_INSTANCE=1 is set as an environment variable (env.JUSTMOCK_INSTANCE=1).

    Regards,
    Kaloyan
    Telerik
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  8. Pawel Paluch
    Pawel Paluch avatar
    10 posts
    Member since:
    Mar 2010

    Posted 02 Jul 2013 Link to this post

    Hello,
    indeed, while messing with project settings i had disabled dotCover:

    when enabled, linked and with env.JUSTMOCK_INSTANCE=1

    results with:
    Test(s) failed. Telerik.JustMock.Core.ElevatedMockingException : Cannot mock 'System.DateTime'. The profiler must be enabled to mock, arrange or execute the specified target.
       at Telerik.JustMock.Core.MocksRepository.„– (Type ‹ , IEnumerable`1 ˆ– , IEnumerable`1 ‰– , IEnumerable`1 Š– , Boolean †– )
       at    .‹– .„– (MocksRepository €– , Type ‹ , Nullable`1    , Boolean †– )
       at Telerik.JustMock.Core.MocksRepository. ˜ (Expression ›• , œ  œ )
       at Telerik.JustMock.Core.MocksRepository.Arrange[ ˜ ](Expression ›• , Func`1  ˜ )
       at Telerik.JustMock.Mock.‹ .Ž ()
       at “• .’• .Š• [– ](Func`1 ‹• )
       at Telerik.JustMock.Mock.Arrange[TResult](Expression`1 expression)
       at NuSoft.Printer.Rs232.Tests.PrinterTest.CheckProfiler() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 19
       at NuSoft.Printer.Rs232.Tests.PrinterTest.AssertStringPrinted() in c:\TeamCity\buildAgent\work\64cb9cb36a4269ed\NuSoft.Printer.Rs232.Tests\PrinterTest.cs:line 29

    and avent with ID:1022 is Informational, stating:
    .NET Runtime version 4.0.30319.17929 - The profiler was loaded successfully. Profiler CLSID: '{fe73d7a7-0cd1-49da-b89e-1c62cf1027b8}'. Process ID (decimal): 6720. Message ID: [0x2507].
  9. Answer
    Stefan
    Admin
    Stefan avatar
    198 posts

    Posted 02 Jul 2013 Link to this post

    Hello Pawel,

    It seems that the linking didn't work - apparently the core dotCover profiler got loaded instead of JustMock's. Linking with dotCover is done only for the current user account. Please, double-check that you're running the configuration tool from the same user account as the the account that later runs the build.

    Regards,
    Stefan
    Telerik
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  10. Pawel Paluch
    Pawel Paluch avatar
    10 posts
    Member since:
    Mar 2010

    Posted 19 Aug 2013 Link to this post

    Hello Stefan,

    Aplologies for late answer, and yes ot worked. Thank you for assistance.

    Regards
    Paweł
Back to Top
DevCraft R3 2016 release webinar banner