C# command line tools for executing unit tests on Android, iOS, WatchOS and AppleTV devices/simulators
Перейти к файлу
Ankit Jain 322e702137
[wasm][test-browser] Improve logging, and retrying (#386)
- Log arguments passed to chromedriver
- Log `driver.log` if the driver crashes

- Re-create ChromeDriverService, when we are retrying. This is because
the exception from a failed chromedriver can show up when creating a
`ChromeDriverService`, or `ChromeDriver`.

- And delete older `driver.log` before starting
2020-12-02 17:36:05 +01:00
eng [master] Update dependencies from dotnet/arcade (#376) 2020-11-24 09:42:51 +00:00
src [wasm][test-browser] Improve logging, and retrying (#386) 2020-12-02 17:36:05 +01:00
tests Address https://github.com/dotnet/runtime/issues/45428 - there's a mystery state where the install cache is full or something, rebooting device helps. Also improve wait-for-device to actually check the boot_completed prop (#388) 2020-12-02 03:50:13 +01:00
tools/Microsoft.DotNet.XHarness.SimulatorInstaller Keep new lines in multi-line log messages (#325) 2020-10-02 20:07:07 +02:00
.editorconfig Resolve all code style warnings in the repo (#267) 2020-06-18 12:06:29 +02:00
.gitattributes Merge pull request #13 from premun/prvysoky/test-command 2020-04-02 09:27:24 -07:00
.gitignore Add an ide config dir to the .gitignore. (#238) 2020-05-28 12:22:59 -04:00
Build.cmd Initial commit of arcade-ifying repo based off minimal-ci sample. Add placeholder XHarness and XHarness.Tests projects 2020-03-18 14:26:13 -07:00
CODE_OF_CONDUCT.md Fix links to Code of Conduct (#22) 2020-04-11 11:18:54 +02:00
Directory.Build.props Initial commit of arcade-ifying repo based off minimal-ci sample. Add placeholder XHarness and XHarness.Tests projects 2020-03-18 14:26:13 -07:00
Directory.Build.targets Initial commit of arcade-ifying repo based off minimal-ci sample. Add placeholder XHarness and XHarness.Tests projects 2020-03-18 14:26:13 -07:00
LICENSE.TXT Initial commit of arcade-ifying repo based off minimal-ci sample. Add placeholder XHarness and XHarness.Tests projects 2020-03-18 14:26:13 -07:00
NuGet.config [master] Update dependencies from dotnet/arcade (#297) 2020-08-19 10:19:13 +02:00
README.md README: Use xharness tool directly (#379) 2020-11-26 10:08:16 +01:00
SECURITY.md Initial SECURITY.md commit 2020-03-16 04:09:12 -07:00
THIRD-PARTY-NOTICES.TXT Initial commit of arcade-ifying repo based off minimal-ci sample. Add placeholder XHarness and XHarness.Tests projects 2020-03-18 14:26:13 -07:00
XHarness.sln Plumbing process usage through IAdbProcessManager, basic tests (#252) 2020-06-09 11:26:42 -07:00
azure-pipelines.yml Update package publishing to v3 (#320) 2020-09-30 17:29:51 +02:00
build.sh Add rollForwardOnNoCandidateFx for CLI tool (#30) 2020-04-15 08:16:03 -07:00
global.json [master] Update dependencies from dotnet/arcade (#376) 2020-11-24 09:42:51 +00:00

README.md

XHarness

This repo contains the code to build the XHarness dotnet tool.

What is XHarness

XHarness is primarily a command line tool that enables running xUnit like tests on Android, Apple iOS / tvOS / WatchOS and desktop Browsers. It can locate devices/emulators, install a given application, run it and collect results uninstalling it after. It handles application crashes by collecting crash dumps and supports different types of connection modes (Network, USB cable). It can output test results in various different formats from text to xUnit/NUnit XML.

Running the tool

The tool requires .NET Core 3.1.201 or later to be run. It is packaged as a dotnet tool command and can be installed using the dotnet tool CLI.

  • The iOS scenarios require you to run the tool on MacOS with full Xcode installation
  • Android scenarios are supported on Linux, macOS and Windows systems
  • Browsers scenarios are supported on Linux systems

To install the tool run:

dotnet tool install Microsoft.DotNet.XHarness.CLI \
    --global \
    --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json \
    --version 1.0.0-prerelease.20229.6

You can get the specific version from the dotnet-eng feed where it is published. So far we are in preview so omitting the version will fail to locate a stable version of the tool and it has to be supplied.

To run the tool, use the xharness command. The tool always expects the platform (android/ios) as the first argument and has following commands available:

  • test - run and test given application containing a TestRunner * on a target device/emulator
  • state - print information about the machine and connected devices
  • run (iOS only) - run given application without a TestRunner * on a target device/emulator

Applications run via the ios test command require a TestRunner inside of the iOS app bundle to work properly. The ios run command, on the other hand, doesn't expect the TestRunner and only runs the application and tries to detect the exit code. Detection of exit code might not work across different iOS versions reliably.

* See the Test Runners section.

Example:

xharness android state

To list all the possible commands, use the help command:

xharness help

To get help for a specific command or sub-command, run:

xharness help ios
xharness help ios test

Other settings

There are other settings which can be controlled via environmental variables and are primarily meant for build pipeline scenarios:

  • XHARNESS_DISABLE_COLORED_OUTPUT - disable colored logging so that control characters are not making the logs hard to read
  • XHARNESS_LOG_WITH_TIMESTAMPS - enable timestamps for logging
  • XHARNESS_LOG_TEST_START - log test start messages, useful to diagnose when tests are hanging. Currently only works for WebAssembly.

Arcade/Helix integration

In case your repository is onboarded into Arcade you can use the Arcade Helix SDK to run XHarness jobs over Helix. More on how to do that is described here.

Examples

To run an iOS app bundle on a 64bit iPhone Simulator:

xharness ios test \
    --app=/path/to/an.app \
    --output-directory=out \
    --targets=ios-simulator-64

or the same can be achieved via the shorthand versions of the same options:

xharness ios test -a=/path/to/an.app -o=out -t=ios-simulator-64

The out dir will then contain log files such as these:

iPhone X (iOS 13.3) - created by xharness.log
run-Simulator_iOS64.log
simulator-list-20200430_025916.log
test-ios-simulator-64-20200430_025916.log
test-ios-simulator-64-20200430_025916.xml

These files are:

  • logs from the Simulator
  • logs from the tool itself
  • logs from getting the list of available Simulators
  • Test results in human readable format
  • Test results in XML format (default is xUnit but can be changed via options)

Test Runners

The repository also contains several TestRunners which are libraries that can be bundled inside of the application and execute the tests. The TestRunner detects and executes unit tests inside of the application. It also connects to XHarness over TCP connection from within the running app bundle and reports test run results/state.

Currently we support Xunit and NUnit test assemblies but the Microsoft.DotNet.XHarness.Tests.Runners supports implementation of custom runner too.

Contribution

We welcome contributions! Please follow the Code of Conduct.

Filing issues

This repo should contain issues that are tied to the XHarness command line tool and the TestRunners.

For other issues, please use the following repos:

  • For .NET runtime and Base Class Library issues, file in the dotnet/runtime repo
  • For overall .NET SDK issues, file in the dotnet/sdk repo

License

.NET (including the xharness repo) is licensed under the MIT license.