running xunit from console

18,522

Solution 1

Two solutions: 1) Add C:\src\Tools\xUnit to your PATH environment variable and run the xunit console app from a command prompt where the current directory is C:\src\projects\MyTestProject\bin.

2) As per the first suggestion but rather then putting it in your PATH environment variable, specify the whole path (relative or absolute) to the xunit.console.exe on the command line as the executable to run.

Solution 2

Way to find xUnitConsole.exe Search the package in

%userprofile%\.nuget\packages

.nuget\packages\xunit.runner.console->Your Version installed->Tools->xUnitConsole.exe

Solution 3

  • Run the Command Prompt

  • Run the next command and replace 'path_to_xunit_console' with the path of xunit console

    set PATH=%PATH%;path_to_xunit_console_exe
    
  • move to location of your unit test binary project:

    cd  my_test_binary_folder   
    
  • Run the next command and save the logs to xml file:

    xunit.console your_test_dll_file   -xml testlog.xml
    

To know the different options run:

   xunit.console -?

You can automate these steps by creating a batch file, test.cmd, in the binary test folder:

 set PATH=%PATH%;path_to_xunit_console_exe
 xunit.console your_test_dll_file   -xml testlog.xml
Share:
18,522
Raif
Author by

Raif

Updated on July 20, 2022

Comments

  • Raif
    Raif almost 2 years

    I have, what is probably, a stupid question.

    I'm trying to run an xunit dll from the command prompt.

    I find that I need the following dlls to be in the folder that the command prompt is in.

    xUnit.Console.exe,xunit.console.exe.config,xunit.dll,xunit.runner.utility.dll
    

    which is fine I guess but then I can't get it to run my tests.

    At first I tried using a relative path to my test dll and it was not having that.

    so then I put the test dll in a folder with the above dlls and ran it. Now the result is it says I"m missing a dependency for my test dll.

    So then I put the xunit files in the bin folder with my test project dlls and it tells me that it can't even find the test dll that it's sitting next to.

    This all seems very difficult what i want is to do this given the following structure

    --src
    
    ----tools
    
    ------xUnit
    
    --------all my xunit dlls
    
    ----projects
    
    ------MyTestProject
    
    -------bin
    
    ---------MyTestProject.dll
    

    lets say

    c:\Src\Tools\xUnit>xunit.console ..\\..\Projects\MyTestProject\bin\MyTestProject.dll
    
  • Josh Gallagher
    Josh Gallagher over 6 years
    Could the downvoter explain why the answer didn't work for them?