-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (46 loc) · 1.54 KB
/
Program.cs
File metadata and controls
57 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using System.Reflection;
using Microsoft.DotNet.XHarness.TestRunners.Common;
using Microsoft.DotNet.XHarness.TestRunners.Xunit.v3;
namespace XunitV3Sample;
// Sample test class using xunit v3
public class SampleTests
{
[Fact]
public void BasicTest()
{
Assert.True(true);
}
[Fact]
public void AnotherTest()
{
Assert.Equal(4, 2 + 2);
}
}
// Entry point demonstrating xunit v3 runner usage
public class Program : WasmApplicationEntryPoint
{
public static async Task Main(string[] args)
{
Console.WriteLine("xunit v3 Sample Application");
using var writer = new StringWriter();
var logger = new LogWriter(writer);
var runner = new XUnitTestRunner(logger);
// Run tests in this assembly
var assemblyInfo = new TestAssemblyInfo(
Assembly: Assembly.GetExecutingAssembly(),
AssemblyPath: Assembly.GetExecutingAssembly().Location
);
await runner.Run(new[] { assemblyInfo });
// Output results
Console.WriteLine("Test Results:");
var results = runner.ConsumeAssembliesElement();
Console.WriteLine(results.ToString());
Console.WriteLine("\nLogger Output:");
Console.WriteLine(writer.ToString());
}
}