How to execute NUnit test cases from command prompt

前端 未结 6 1493
难免孤独
难免孤独 2021-02-07 00:30

How can I execute a test case from Command Console using NUnit? I had set of Selenium Tests written in C# based on NUnit framework. I need to execute the test cases simply by ru

相关标签:
6条回答
  • 2021-02-07 00:51
    • Working on a Windows 10 Desktop with Visual Studio
    • I had a set of tests in C# where I'd set the test method with Category==API.
    • To run the tests (Nunit3-console) remotely via Bamboo, I added this Bamboo Powershell script:

      Invoke-Command -Credential $credentials -ComputerName $Server -ScriptBlock{
           $pathToDdrive = "D:"
           $pathtoDLL = Join-Path $pathToDdrive -ChildPath "RestOfThePathToDLL"
      
           cd D:\...\NUnit.ConsoleRunner.3.10.0\tools
           .\nunit3-console.exe $pathToDLL --where "cat=='API'" 
      } 
      
    0 讨论(0)
  • 2021-02-07 00:54

    Use nunit-console.exe to run tests from the command line.

    For example:

    nunit-console.exe /xml:results.xml path/to/test/assembly.dll
    

    This will run the unit tests and save the results in the results.xml file, which you can work with easily.

    See the documentation for all of the various command line switches that are available.

    0 讨论(0)
  • 2021-02-07 00:58

    Visual Studio: 2017, 2019(Preview) On Mac use below command:

    nunit-console <path/to/project>/<project-name>/bin/Debug/<project-solution-name>.dll
    

    For example:

    nunit-console /Users/pratik/Projects/selenium-mac13/selenium-test/bin/Debug/selenium-test.dll

    0 讨论(0)
  • 2021-02-07 00:58

    nunit3-console.exe "path of the testfile (dll)"

    0 讨论(0)
  • 2021-02-07 01:12

    I've just find another nice solution:

    Adding the following command to the "Build Events" / "Post-Build Events", will run the tests in Nunit-Gui automatically after the project has been built.

    I hope this can be useful:

    "C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-x86.exe" $(TargetPath) /run
    
    0 讨论(0)
  • 2021-02-07 01:16

    I would like to add a few words about the latest version of NUnit. The name of the console application has changed to nunit3-console.exe in NUnit 3. Information about all possible options can be found in the official documentation. For example, run all tests in the assembly (the results are saved into the TestResult.xml file by default).

    nunit3-console.exe path/to/test/assembly.dll
    
    0 讨论(0)
提交回复
热议问题