NUnit Test Runner for Sitecore

NUnit Test Runner for Sitecore

By | | Sitecore , Unit Testing

Why

One of the techniques used for testing Sitecore is using embedded test runner. You can find more information in this book and some videos from codeflood.

Features

This test runner will allow you to run all nunit test on a test suite, but also filter by category, text fixture and run individual tests. It will also generate a TestResult.xml file based on the Nunit test result.

Settings

  • NUnitTestRunnerEnabled to enable/disable the test runner
  • NUnitTestRunnerRoute to set the route. The default route is testrunner and you should be able to access the test runner using your browser http://youhost/testnunner/
  • NUnitTestRunnerPath is the default path to the dll containing the tests, example ScBootstrap.Tests.dll asumming the dll is in the bin folder or a full path i.eC:\YourPath\NUnitContrib.Web.TestExamples.dll. This setting is mandatory
  • NUnitTestRunnerResultPath is the output file for the test result. The default value is TestResult.xml meaning that it will be saved on your bin folder. You can also provide a full path, i.e, C:\Temp\TestResult.xml. Please make sure the process has write access to that file.

Configuration file example

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="NUnitContrib.Web.TestRunner.Pipelines.RunnerConfig, NUnitContrib.Web.TestRunner" />
      </initialize>
    </pipelines>
    <settings>
      <setting name="NUnitTestRunnerEnabled" value="true" />       <setting name="NUnitTestRunnerRoute" value="testrunner"/>       <!--<setting name="NUnitTestRunnerRoute" value="tests"/>-->       <setting name="NUnitTestRunnerPath" value="ScBootstrap.Tests.dll"/>       <!--<setting name="NUnitTestRunnerPath" value="C:\Projects\TestRunner\src\TestExamples\bin\Debug\NUnitContrib.Web.TestExamples.dll"/>-->       <setting name="NUnitTestRunnerResultPath" value="TestResult.xml"/>       <!--<setting name="NUnitTestRunnerResultPath" value="C:\Temp\TestResult.xml"/>-->
    </settings>   </sitecore> </configuration>

License and source code

Code licensed under the The MIT license and you can find the source code on github.

About us

We are based in Barcelona and specialize in medium and large Umbraco projects. We offer our experience, method and commitment to achieve the success of every project. We have been an official Umbraco partner since 2011.

All Categories