First attempt with a unit-test: Core.TestContext error?

6 posts, 0 answers
  1. James
    James avatar
    7 posts
    Member since:
    Mar 2011

    Posted 11 Aug 2011 Link to this post

    Hello, after using NUnit with the Jetbrains test-runner, I decided to give this Testing Framework a try. Following the guide within the Test Studio documentation, the last section titled "Telerik Testing Framework", within the section describing getting started using NUnit - I created a new unit-test class using the Telerik template, for NUnit-Wpf.  I added the NUnit references to the project.

    But there is a compile error that I don't see addressed within the guide. Within the region WebAii Initialization..

    Initialize(new TestContextWriteLine(Core.TestContext.Out.WriteLine));

    The TestContext member is not found, resulting in a compilation error. I can comment this out of course -- but I'm wondering if this indicates a problem with the configuratioin, or what?  (see first attached screenshot)

    Incidentally, also within the guide - there is a link to download the NUnit web extensions source. But the link takes you to a Telerik product page and I am not seeing any path from that page to get you to the NUnit web extensions source. Is this a typo? (see second screenshot)

    If I am creating a unit-test for my desktop WPF app, why is a "NUnit-Wpf" project template including WebAii initialization anyway? This is not a web application.

    I appreciate your advice and help, thanks.

    James W. Hurst
  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 15 Aug 2011 Link to this post

    Hi James,
       you're right - the link for the Nunit Extension is incorrect. I've logged this and it will be rectified. However, you don't need that link in order to add a reference to Nunit.Core. I assume you already have the following using statement in your test:
    using Core = NUnit.Core;
    It's part of the default Nunit test template.

    Now you have to add Nunit.Core to your project references. If you have Nunit installed (which you should if you want to run Nunit tests) then this DLL is located in the installation folder for Nunit. On my machine I found it in the following location:
    c:\Program Files(x86)\NUnit 202.5.10\bin\net-2.0\lib\nunit.core.dll

    Just add it to your project references from this location.

    Kind regards,
    Stoich
    the Telerik team
    Vote for Telerik Test Studio at the Annual Automation Honors Voting!
  3. Lionel
    Lionel avatar
    1 posts
    Member since:
    Mar 2011

    Posted 18 Aug 2011 Link to this post

    Even if you add the reference to nunit.core you have the problem.

    TestContext class is not there. 
    Nunit version is 2.5.5.10112
  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 18 Aug 2011 Link to this post

    Hello Lionel,

    Yes, NUnit moved the function on us in their API. Try this instead:

    Initialize(false, new TestContextWriteLine(Core.TestExecutionContext.CurrentContext.LogWriter.WriteLine));

    Best wishes,
    Cody
    the Telerik team
    Vote for Telerik Test Studio at the Annual Automation Honors Voting!
  5. Daniel Corbett
    Daniel Corbett avatar
    24 posts
    Member since:
    Jun 2009

    Posted 23 Sep 2011 Link to this post

    Unfortunately, your fix isn't complete...

    At least with NUnit. 2.5.10,  In this latest version of NUnit,  Nunit.Framework.TestContext.Out doesn't exist.

    Seems like the feature is gone from NUnit.  I can't find a compatible fix, except to comment it out.

    Suggestions?

       - Daniel
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Sep 2011 Link to this post

    Hi Daniel Corbett,

    I just installed NUnit-2.5.10.11092 and find that the same code works as expected. Can you double check the file path to your NUnit.core.dll file (see attached screen shot)?

    All the best,
    Cody
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top