Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,38 @@ public override void OnCreate(Bundle? arguments)
Start();
}

public override void OnStart()
public override async void OnStart()
{
base.OnStart();

Task.Run(async () =>
var consumer = new ResultConsumer(this);
var bundle = new Bundle();
try
{
var consumer = new ResultConsumer(this);
var bundle = new Bundle();
try
{
var writeablePath = Application.Context.GetExternalFilesDir(null)?.AbsolutePath ?? Path.GetTempPath();
var resultsPath = Path.Combine(writeablePath, "TestResults");
var builder = await TestApplication.CreateBuilderAsync([
"--results-directory", resultsPath,
"--report-trx"
]);
builder.AddMSTest(() => [GetType().Assembly]);
builder.AddTrxReportProvider();
builder.TestHost.AddDataConsumer(_ => consumer);
var writeablePath = Application.Context.GetExternalFilesDir(null)?.AbsolutePath ?? Path.GetTempPath();
var resultsPath = Path.Combine(writeablePath, "TestResults");
var builder = await TestApplication.CreateBuilderAsync([
"--results-directory", resultsPath,
"--report-trx"
]);
builder.AddMSTest(() => [GetType().Assembly]);
builder.AddTrxReportProvider();
builder.TestHost.AddDataConsumer(_ => consumer);

using ITestApplication app = await builder.BuildAsync();
await app.RunAsync();
using ITestApplication app = await builder.BuildAsync();
await app.RunAsync();

bundle.PutInt("passed", consumer.Passed);
bundle.PutInt("failed", consumer.Failed);
bundle.PutInt("skipped", consumer.Skipped);
bundle.PutString("resultsPath", consumer.TrxReportPath);
Finish(Result.Ok, bundle);
}
catch (Exception ex)
{
bundle.PutString("error", ex.ToString());
Finish(Result.Canceled, bundle);
}
});
bundle.PutInt("passed", consumer.Passed);
bundle.PutInt("failed", consumer.Failed);
bundle.PutInt("skipped", consumer.Skipped);
bundle.PutString("resultsPath", consumer.TrxReportPath);
Finish(Result.Ok, bundle);
}
catch (Exception ex)
{
bundle.PutString("error", ex.ToString());
Finish(Result.Canceled, bundle);
}
}

class ResultConsumer(Instrumentation instrumentation) : IDataConsumer
Expand Down