Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8187919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:43:51+00:00 2026-06-07T02:43:51+00:00

When I build a Visual Studio 2010 project, I want to run unit tests

  • 0

When I build a Visual Studio 2010 project, I want to run unit tests with NUnit and display test results only when some tests have failed.

I have setup a post-build event in Visual Studio to call a batch file like below:

$(ProjectDir)RunUnitTest.bat "$(SolutionDir)packages\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe" "$(TargetPath)"

Then in RunUnitTest.bat, I call nunit-console.exe and pass in the test project dll.

@echo off    
REM runner is the full path to nunit-console.exe
set runner=%1    
REM target is the full path to the dll containing unit tests
set target=%2    
"%runner%" "%target%"    
if errorlevel 1 goto failed
if errorlevel 0 goto passed    
:failed
echo some tests failed
goto end    
:passed
echo all tests passed
goto end    
:end
echo on

After that, NUnit generates TestResult.xml containing test results, so how do I display it in user friendly way? It’ll be the best if it displays inside Visual Studio, but other options are open too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:43:53+00:00Added an answer on June 7, 2026 at 2:43 am

    I ended up using nunit-summary to generate all pass summary html reports and nunit-results to create failed test reports in html.

    This approach is quiet easy to setup.

    First, download nunit-summary and nunit-results from launchpad and put them in TestRunner folder under the test project.

    Then, add a post-build event to call a batch file.

    Lastly, add the batch file to TestRunner folder under test project. It should contain the following files at the least:

    • nunit-results.exe
    • nunit-results.tests.dll
    • nunit-results.tests.pdb
    • nunit-summary.exe
    • `nunit-core.dll
    • nunit.util.dll
    • RunUnitTests.bat

    Post-build event for the project containing unit tests:

    "$(ProjectDir)TestRunner\RunUnitTests.bat" "$(SolutionDir)packages\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe" "$(TargetPath)" "$(TargetDir)"
    

    Scripts in RunUnitTest.bat

    REM     This batch file does the followings:
    REM     1. runs unit test with nunit-console.exe and produces a TestResult.xml
    REM     2. if one or more tests failes, it calls unit-results.exe to convert TestResult.xml to 
    REM     Usage: RunUnitTests.bat "path-to-nunit.exe" "path-to-test.dll" "path-to-output-folder"
    
    @echo off
    
    REM get input arguments
    set runner=%1
    set target=%2
    set output=%3
    
    REM remove double quotes
    set runner=%runner:"=%
    set target=%target:"=%
    set output=%output:"=%
    
    REM prepare and clean up TestResult folder
    if not exist "%output%TestResults\nul" md "%output%TestResults"
    del "%output%\TestResults\*.*" /q
    
    "%runner%" "%target%"
    
    if errorlevel 1 goto failed
    if errorlevel 0 goto passed
    
    :failed
    echo some tests failed
    "%~dp0nunit-results.exe" "%output%TestResult.xml"
    "%output%TestResults\index.html"
    exit 1
    
    :passed
    echo all tests passed
    "%~dp0nunit-summary.exe" "%output%TestResult.xml" -out=TestResults\TestSummary.html
    "%output%TestResults\TestSummary.html"
    exit 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering running unit tests for my Visual Studio 2010 projects on our build
I have created SQL Server 2008 Database project using visual studio 2010. after build
hello i build a webservice in visual studio 2010. i get some id's which
I'm have a c# visual studio 2010 project that uses [Conditional(DEBUG)] above some of
In Visual Studio 2010 we have under 'tools|options|projects and solutions|build and run' (couldn't find
I'm new to project configuration in Visual Studio 2010, but I've done some research
By default, Visual Studio (2010 as well as 11 beta) builds every project in
I can build locally with Visual Studio 2010, but our automatic builds fail reading
For reference, I'm using Visual Studio 2010. I have a custom build step defined
I am running Visual Studio 2010. I have a XSD schema and want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.