{"id":16687126,"url":"https://github.com/redth/unittests.headlessrunner","last_synced_at":"2025-04-10T00:17:34.824Z","repository":{"id":137487538,"uuid":"124317284","full_name":"Redth/UnitTests.HeadlessRunner","owner":"Redth","description":"A platform agnostic netstandard20 unit test runner","archived":false,"fork":false,"pushed_at":"2018-04-03T19:37:43.000Z","size":50,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:17:27.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Redth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-08T01:17:23.000Z","updated_at":"2023-01-26T10:47:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"c644b82d-b83b-456e-9fd5-98739224584e","html_url":"https://github.com/Redth/UnitTests.HeadlessRunner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redth%2FUnitTests.HeadlessRunner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redth%2FUnitTests.HeadlessRunner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redth%2FUnitTests.HeadlessRunner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redth%2FUnitTests.HeadlessRunner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Redth","download_url":"https://codeload.github.com/Redth/UnitTests.HeadlessRunner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131318,"owners_count":21052820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T15:07:51.697Z","updated_at":"2025-04-10T00:17:34.814Z","avatar_url":"https://github.com/Redth.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UnitTests.HeadlessRunner\n\nThere are several good options for running xUnit / NUnit tests on devices (iOS/Android), but they all work a little differently and they reside in different silos.  I could not find a great platform independent solution which would allow me to retrieve device test results from off of the device/emulator in a known format.\n\nThe Xamarin.Android team has [done some great work in building a test runner](https://github.com/xamarin/xamarin-android/tree/master/tests) that is almost platform independent.  I've borrowed the code, made it into a .netstandard 2.0 library that is easily consumable within any .NET app.\n\n## Platform agnostic test result retrieval\n\nMy goal was to be able to support Android, iOS *and* UWP with this project.  There are different ways between platforms which one could use to retrieve test results from a device.  On Android, we could `adb pull` the test results file.  On iOS, if we use a simulator, we could just find the simulator's location on disk and copy over the test result file (but of course runnign on an actual device is another story).\n\nInstead of maintaining these different methods (and figuring out how to do this on UWP at all), I decided to leverage one universal communication mechanism: *sockets*.\n\nThe idea is that you somehow (either hard code, inject during compilation or otherwise) tell the test runner application a *host address* and *host port* to connect to via TCP socket to send all the test result data to.  This means whatever invokes the actual test runner application needs to be listening on the socket for data.\n\nWhen the data transmission completes, we know the tests are finished, and the test runner application can be terminated.\n\n## Test Runner\n\nTo discover and run tests within any of your applications, at some point you will want to add the following code:\n\n```csharp\nUnitTests.HeadlessRunner.Tests.RunAsync (\n    \"192.168.1.100\",\n    10578,\n    typeof(MyTestClass).Assembly);\n```\n\n## Test Result Listener\n\nReally you can use any simple tcp socket listening to accept the raw ASCII endcoded xml file data, however I've also added a helper method to the library as well:\n\n```csharp\nvar listenTask = UnitTests.HeadlessRunner.Tests.ListenAsync (\n    port: 10578,\n    saveTestResultsFilename: \"nunit-results.xml\",\n    TimeSpan.FromSeconds(60));\n\n// Start your test runner app now\n\nlistenTask.Wait ();\n\n// Terminate your test runner app\n```\n\n\n## Limitations\n - xUnit only support (NUnit may be added later)\n - No choice in test result format - NUnit XML is the default","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredth%2Funittests.headlessrunner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredth%2Funittests.headlessrunner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredth%2Funittests.headlessrunner/lists"}