Page MenuHomePhorge
Diviner Arcanist Tech Docs CSharpToolsTestEngine

final class CSharpToolsTestEngine
Arcanist Technical Documentation (Unit Testing)

Uses cscover (http://github.com/hach-que/cstools) to report code coverage.

This engine inherits from XUnitTestEngine, where xUnit is used to actually run the unit tests and this class provides a thin layer on top to collect code coverage data with a third-party tool.

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

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()
Inherited

XUnitTestEngine

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()
Inherited

XUnitTestEngine

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()

XUnitTestEngine

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.

CSharpToolsTestEngine

Overridden version of loadEnvironment to support a different set of configuration values and to pull in the cstools config for code coverage.

Return
void

public function mapPathsToResults($paths)
Inherited

XUnitTestEngine

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)
Inherited

XUnitTestEngine

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)
Inherited

XUnitTestEngine

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()
Inherited

XUnitTestEngine

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)
Inherited

XUnitTestEngine

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)

XUnitTestEngine

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

CSharpToolsTestEngine

Overridden version of buildTestFuture so that the unit test can be run via cscover, which instruments assemblies and reports on code coverage.

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)
Inherited

XUnitTestEngine

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($cover_file)

XUnitTestEngine

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).

CSharpToolsTestEngine

Returns coverage results for the unit tests.

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)
Inherited

XUnitTestEngine

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.

private function assemblyShouldBeInstrumented($file)

Returns whether the specified assembly should be instrumented for code coverage reporting. Checks the excluded file list and the matching regex if they are configured.

Parameters
$file
Return
booleanWhether the assembly should be instrumented.

private function getCachedResultsIfPossible($cover_file)

Retrieves the cached results for a coverage result file. The coverage result file is XML and can be large depending on what has been instrumented so we cache it in case it's requested again.

Parameters
string$cover_fileThe name of the coverage file.
Return
arrayCode coverage results, or null if not cached.

private function addCachedResults($cover_file, $results)

Stores the code coverage results in the cache.

Parameters
string$cover_fileThe name of the coverage file.
array$resultsThe results to cache.
Return
wild

private function processTags($tags)

Processes a set of XML tags as code coverage results. We parse the instrumented and executed tags with this method so that we can access the data multiple times without a performance hit.

Parameters
array$tagsThe array of XML tags to parse.
Return
arrayA PHP array containing the data.

public function readCoverage($cover_file)

Reads the code coverage results from the cscover results file.

Parameters
string$cover_fileThe path to the code coverage file.
Return
arrayThe code coverage results.