Make Device Test results specify platform in names (#121)

One drawback to a shared test project is that the namespace and class names aren’t descriptive of the platform they are running on.  When merging all the test results in CI systems, we lose the ability to easily identify where a test case was ran (especially if it failed).

This will quickly replace some text in the test results file to be specific about the platform each test was run on.
This commit is contained in:
Jonathan Dick 2018-03-27 15:27:02 -04:00 коммит произвёл GitHub
Родитель 2347b5f531
Коммит ac7c161476
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -43,6 +43,15 @@ Func<int, FilePath, Task> DownloadTcpTextAsync = (int port, FilePath filename) =
stream.CopyTo(file);
});
Action<FilePath, string> AddPlatformToTestResults = (FilePath testResultsFile, string platformName) => {
if (FileExists(testResultsFile)) {
var txt = FileReadText(testResultsFile);
txt = txt.Replace("<test-case name=\"Caboodle.DeviceTests.", $"<test-case name=\"Caboodle.DeviceTests.{platformName}.");
txt = txt.Replace("name=\"Test collection for Caboodle.DeviceTests.", $"name=\"Test collection for Caboodle.DeviceTests.{platformName}.");
FileWriteText(testResultsFile, txt);
}
};
Task ("build-ios")
.Does (() =>
{
@ -107,6 +116,8 @@ Task ("test-ios-emu")
Information("Waiting for tests...");
tcpListenerTask.Wait ();
AddPlatformToTestResults(IOS_TEST_RESULTS_PATH, "iOS");
// Close up simulators
Information("Closing Simulator");
ShutdownAllAppleSimulators ();
@ -215,6 +226,8 @@ Task ("test-android-emu")
Information("Waiting for tests...");
tcpListenerTask.Wait ();
AddPlatformToTestResults(ANDROID_TEST_RESULTS_PATH, "Android");
// Close emulator
emu.Kill();
});
@ -272,6 +285,8 @@ Task ("test-uwp-emu")
Information("Waiting for tests...");
tcpListenerTask.Wait ();
AddPlatformToTestResults(UWP_TEST_RESULTS_PATH, "UWP");
// Uninstall the app (this will terminate it too)
uninstallPS();
});