Page MenuHomePhabricator

class XUnitTestEngine
libphutil Technical Documentation ()

Uses xUnit (http://xunit.codeplex.com/) to test C# code.

Assumes that when modifying a file with a path like SomeAssembly/MyFile.cs, that the test assembly that verifies the functionality of SomeAssembly is located at SomeAssembly.Tests.

Methods

final public function __construct()
Inherited

This method is not documented.
Return
this//Implicit.//

public function getEngineConfigurationName()
Inherited

This method is not documented.
Return
wild

final public function setRunAllTests($run_all_tests)
Inherited

This method is not documented.
Parameters
$run_all_tests
Return
wild

final public function getRunAllTests()
Inherited

This method is not documented.
Return
wild

protected function supportsRunAllTests()

This test engine supports running all tests.

Return
wild

final public function setConfigurationManager($configuration_manager)
Inherited

This method is not documented.
Parameters
ArcanistConfigurationManager$configuration_manager
Return
wild

final public function getConfigurationManager()
Inherited

This method is not documented.
Return
wild

final public function setWorkingCopy($working_copy)
Inherited

This method is not documented.
Parameters
ArcanistWorkingCopyIdentity$working_copy
Return
wild

final public function getWorkingCopy()
Inherited

This method is not documented.
Return
wild

final public function setPaths($paths)
Inherited

This method is not documented.
Parameters
array$paths
Return
wild

final public function getPaths()
Inherited

This method is not documented.
Return
wild

final public function setEnableCoverage($enable_coverage)
Inherited

This method is not documented.
Parameters
$enable_coverage
Return
wild

final public function getEnableCoverage()
Inherited

This method is not documented.
Return
wild

final public function setRenderer($renderer)
Inherited

This method is not documented.
Parameters
ArcanistUnitRenderer$renderer
Return
wild

public function run()

Main entry point for the test engine. Determines what assemblies to build and test based on the files that have changed.

Return
arrayArray of test results.

public function shouldEchoTestResults()
Inherited

ArcanistUnitTestEngine

Modify the return value of this function in the child class, if you do not need to echo the test results after all the tests have been run. This is the case for example when the child class prints the tests results while the tests are running.

Return
wild

protected function loadEnvironment()

Determines what executables and test paths to use. Between platforms this also changes whether the test engine is run under .NET or Mono. It also ensures that all of the required binaries are available for the tests to run successfully.

Return
void

public function mapPathsToResults($paths)

Applies the discovery rules to the set of paths specified.

Parameters
array$pathsArray of paths.
Return
arrayArray of paths to test projects and assemblies.

public function runAllTests($test_projects)

Builds and runs the specified test assemblies.

Parameters
array$test_projectsArray of paths to test project files.
Return
arrayArray of test results.

private function resultsContainFailures($results)

Determine whether or not a current set of results contains any failures. This is needed since we build the assemblies as part of the unit tests, but we can't run any of the unit tests if the build fails.

Parameters
array$resultsArray of results to check.
Return
boolIf there are any failures in the results.

private function generateProjects()

If the Build directory exists, we assume that this is a multi-platform project that requires generation of C# project files. Because we want to test that the generation and subsequent build is whole, we need to regenerate any projects in case the developer has added files through an IDE and then forgotten to add them to the respective .definitions file. By regenerating the projects we ensure that any missing definition entries will cause the build to fail.

Return
arrayArray of test results.

private function buildProjects($test_assemblies)

Build the projects relevant for the specified test assemblies and return the results of the builds as test results. This build also passes the "SkipTestsOnBuild" parameter when building the projects, so that MSBuild conditionals can be used to prevent any tests running as part of the build itself (since the unit tester is about to run each of the tests individually).

Parameters
array$test_assembliesArray of test assemblies.
Return
arrayArray of test results.

protected function buildTestFuture($test_assembly)

Build the future for running a unit test. This can be overridden to enable support for code coverage via another tool.

Parameters
string$test_assemblyName of the test assembly.
Return
arrayThe future, output filename and coverage filename stored in an array.

private function testAssemblies($test_assemblies)

Run the xUnit test runner on each of the assemblies and parse the resulting XML.

Parameters
array$test_assembliesArray of test assemblies.
Return
arrayArray of test results.

protected function parseCoverageResult($coverage)

Returns null for this implementation as xUnit does not support code coverage directly. Override this method in another class to provide code coverage information (also see CSharpToolsUnitEngine).

Parameters
string$coverageThe name of the coverage file if one was provided by `buildTestFuture`.
Return
arrayCode coverage results, or null.

private function parseTestResult($xunit_tmp, $coverage)

Parses the test results from xUnit.

Parameters
string$xunit_tmpThe name of the xUnit results file.
string$coverageThe name of the coverage file if one was provided by `buildTestFuture`. This is passed through to `parseCoverageResult`.
Return
arrayTest results.