All Implemented Interfaces:
ExtensionPoint, Describable<Builder>, BuildStep, SimpleBuildStep

public final class Test extends MSBuildCommand
A build step to run "dotnet test", running unit tests for a project, using its configured runner.
  • Constructor Details

    • Test

      @DataBoundConstructor public Test()
      Creates a new "dotnet test" build step.
  • Method Details

    • addCommandLineArguments

      protected void addCommandLineArguments(@NonNull DotNetArguments args)
      Adds command line arguments for this "dotnet test" invocation.

      This adds:

      1. Any arguments added by MSBuildCommand.addCommandLineArguments(DotNetArguments).
      2. -f:xxx, if a target framework moniker has been specified via setFramework(String).
      3. -r:xxx, if a runtime identifier has been specified via setRuntime(String).
      4. --blame, if requested via setBlame(boolean).
      5. --blame-crash, if requested via setBlameCrash(boolean).
      6. --blame-crash-collect-always, if requested via setBlameCrashCollectAlways(boolean).
      7. --blame-crash-dump-type xxx, if requested via setBlameCrashDumpType(String).
      8. --blame-hang, if requested via setBlameHang(boolean).
      9. --blame-hang-dump-type xxx, if requested via setBlameHangDumpType(String).
      10. --blame-hang-timeout nnn, if requested via setBlameHangTimeout(Integer).
      11. --collect xxx, if a data collector has been specified via setCollect(String).
      12. --diag xxx, if a diagnostics file has been specified via setDiag(String).
      13. --filter xxx, if a filter expression has been specified via setFilter(String).
      14. --list-tests, if requested via setListTests(boolean).
      15. --logger xxx, if a logger has been specified via setLogger(String).
      16. --no-build, if requested via setNoBuild(boolean).
      17. --no-restore, if requested via setNoRestore(boolean).
      18. --results-directory xxx, if a results directory has been specified via setResultsDirectory(String).
      19. --settings xxx, if a .runsettings file has been specified via setSettings(String).
      20. --test-adapter-path xxx, if a test adapter path has been specified via setTestAdapterPath(String).
      21. -- name=value [name=value], for all settings specified via setRunSettings(Map) or setRunSettingsString(String).
      Overrides:
      addCommandLineArguments in class MSBuildCommand
      Parameters:
      args - The current set of arguments.
    • isBlame

      public boolean isBlame()
      Determines whether tests should be run in blame mode, to diagnose test host crashes.
      Returns:
      true when tests are run in blame mode; false otherwise.
    • setBlame

      @DataBoundSetter public void setBlame(boolean blame)
      Determines whether tests should be run in blame mode, to diagnose test host crashes.
      Parameters:
      blame - true to run tests in blame mode; false otherwise.
    • isBlameCrash

      public boolean isBlameCrash()
      Determines whether crash dumps should be collected in blame mode.
      Returns:
      true when crash dumps are collected; false otherwise.
    • setBlameCrash

      @DataBoundSetter public void setBlameCrash(boolean blameCrash)
      Determines whether crash dumps should be collected in blame mode.
      Parameters:
      blameCrash - true to collect crash dumps; false otherwise.
    • isBlameCrashCollectAlways

      public boolean isBlameCrashCollectAlways()
      Determines whether crash dumps should be collected in blame mode even for expected test host termination.
      Returns:
      true when crash dumps are collected even for expected test host termination; false otherwise.
    • setBlameCrashCollectAlways

      @DataBoundSetter public void setBlameCrashCollectAlways(boolean blameCrashCollectAlways)
      Determines whether crash dumps should be collected in blame mode even for expected test host termination.
      Parameters:
      blameCrashCollectAlways - true to collect crash dumps even for expected test host termination; false otherwise.
    • getBlameCrashDumpType

      @CheckForNull public String getBlameCrashDumpType()
      Gets the type of dump to collect when the test host terminates unexpectedly.
      Returns:
      The type of dump to collect when the test host terminates unexpectedly.
    • setBlameCrashDumpType

      @DataBoundSetter public void setBlameCrashDumpType(@CheckForNull String blameCrashDumpType)
      Sets the type of dump to collect when the test host terminates unexpectedly.
      Parameters:
      blameCrashDumpType - The type of dump to collect when the test host terminates unexpectedly.
    • isBlameHang

      public boolean isBlameHang()
      Determines whether test timeouts should result in termination.
      Returns:
      true when test timeouts result in termination; false otherwise.
    • setBlameHang

      @DataBoundSetter public void setBlameHang(boolean blameHang)
      Determines whether test timeouts should result in termination.
      Parameters:
      blameHang - true to terminate execution when a test times out; false otherwise.
    • getBlameHangDumpType

      @CheckForNull public String getBlameHangDumpType()
      Gets the type of dump to collect when a test times out.
      Returns:
      The type of dump to collect when a test times out.
    • setBlameHangDumpType

      @DataBoundSetter public void setBlameHangDumpType(@CheckForNull String blameHangDumpType)
      Sets the type of dump to collect when a test times out.
      Parameters:
      blameHangDumpType - The type of dump to collect when a test times out.
    • getBlameHangTimeout

      @CheckForNull public Integer getBlameHangTimeout()
      Gets the timeout (in milliseconds) to use for hang detection.
      Returns:
      The timeout (in milliseconds) to use for hang detection.
    • setBlameHangTimeout

      @DataBoundSetter public void setBlameHangTimeout(@CheckForNull Integer blameHangTimeout)
      Sets the timeout (in milliseconds) to use for hang detection.
      Parameters:
      blameHangTimeout - The timeout (in milliseconds) to use for hang detection.
    • getCollect

      @CheckForNull public String getCollect()
      Gets the data collector to use.
      Returns:
      The data collector to use.
    • setCollect

      @DataBoundSetter public void setCollect(@CheckForNull String collect)
      Sets the data collector to use.
      Parameters:
      collect - The data collector to use.
    • getDiag

      @CheckForNull public String getDiag()
      Gets the path to the diagnostics file to use.
      Returns:
      The path to the diagnostics file to use.
    • setDiag

      @DataBoundSetter public void setDiag(@CheckForNull String diag)
      Sets the path to the diagnostics file to use.
      Parameters:
      diag - The path to the diagnostics file to use.
    • getFilter

      @CheckForNull public String getFilter()
      Gets the filter expression to use.
      Returns:
      The filter expression to use.
    • setFilter

      @DataBoundSetter public void setFilter(@CheckForNull String filter)
      Sets the filter expression to use.
      Parameters:
      filter - The filter expression to use.
    • getFramework

      @CheckForNull public String getFramework()
      Gets the target framework moniker to use.
      Returns:
      The target framework moniker to use.
    • setFramework

      @DataBoundSetter public void setFramework(@CheckForNull String framework)
      Sets the target framework moniker to use.
      Parameters:
      framework - The target framework moniker to use.
    • isListTests

      public boolean isListTests()
      Determines whether discovered tests should be listed.
      Returns:
      true when discovered tests are listed; false otherwise.
    • setListTests

      @DataBoundSetter public void setListTests(boolean listTests)
      Determines whether discovered tests should be listed.
      Parameters:
      listTests - true to list discovered tests; false otherwise.
    • getLogger

      @CheckForNull public String getLogger()
      Gets the logger to use.
      Returns:
      The logger to use.
    • setLogger

      @DataBoundSetter public void setLogger(@CheckForNull String logger)
      Sets the logger to use.
      Parameters:
      logger - The logger to use.
    • isNoBuild

      public boolean isNoBuild()
      Determines whether a build should be performed before running tests.
      Returns:
      true when neither a restore nor a build will be performed before running tests; false otherwise.
    • setNoBuild

      @DataBoundSetter public void setNoBuild(boolean noBuild)
      Determines whether a build should be performed before running tests.
      Parameters:
      noBuild - true to perform neither a restore nor a build before running tests; false otherwise.
    • isNoRestore

      public boolean isNoRestore()
      Determines whether an implicit restore should be executed as part of this command.
      Returns:
      true when the implicit restore is disabled; false otherwise.
    • setNoRestore

      @DataBoundSetter public void setNoRestore(boolean noRestore)
      Determines whether an implicit restore should be executed as part of this command.
      Parameters:
      noRestore - true to disable the implicit restore; false otherwise.
    • getResultsDirectory

      @CheckForNull public String getResultsDirectory()
      Gets the directory to store test results in.
      Returns:
      The directory to store test results in.
    • setResultsDirectory

      @DataBoundSetter public void setResultsDirectory(@CheckForNull String resultsDirectory)
      Sets the directory to store test results in.
      Parameters:
      resultsDirectory - The directory to store test results in.
    • getRunSettings

      @CheckForNull public Map<String,String> getRunSettings() throws IOException
      Gets the inline run settings to use.
      Returns:
      The inline run settings to use.
      Throws:
      IOException - When there is a problem loading the run settings into a Java Properties object.
    • setRunSettings

      @DataBoundSetter public void setRunSettings(@CheckForNull Map<String,String> runSettings) throws IOException
      Sets the inline run settings to use.
      Parameters:
      runSettings - The inline run settings to use.
      Throws:
      IOException - When there is a problem using a Properties object to generate a string form for the map.
    • getRunSettingsString

      @CheckForNull public String getRunSettingsString()
      Gets the inline run settings to use.
      Returns:
      The inline run settings to use.
    • setRunSettingsString

      @DataBoundSetter public void setRunSettingsString(@CheckForNull String runSettings)
      Sets the inline run settings to use.
      Parameters:
      runSettings - The inline run settings to use.
    • getRuntime

      @CheckForNull public String getRuntime()
      Gets the runtime identifier to use.
      Returns:
      The runtime identifier to use.
    • setRuntime

      @DataBoundSetter public void setRuntime(@CheckForNull String runtime)
      Sets the runtime identifier to use.
      Parameters:
      runtime - The runtime identifier to use.
    • getSettings

      @CheckForNull public String getSettings()
      Gets the .runsettings file to use.
      Returns:
      The .runsettings file to use.
    • setSettings

      @DataBoundSetter public void setSettings(@CheckForNull String settings)
      Sets the .runsettings file to use.
      Parameters:
      settings - The .runsettings file to use.
    • getTestAdapterPath

      @CheckForNull public String getTestAdapterPath()
      Gets the path to search for test adapters.
      Returns:
      The path to search for test adapters.
    • setTestAdapterPath

      @DataBoundSetter public void setTestAdapterPath(@CheckForNull String testAdapterPath)
      Sets the path to search for test adapters.
      Parameters:
      testAdapterPath - The path to search for test adapters.