Skip to content

Commit 86f53e5

Browse files
committed
Build solution (once) before running tests.
1 parent 3a59da0 commit 86f53e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/AdoNetApiTest/Program.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ static async Task Main(string[] args)
1717
if (args.Length == 0)
1818
{
1919
var assemblyPath = new Uri(Assembly.GetEntryAssembly().Location).AbsolutePath;
20-
var testsPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath), "..", "..", "..", "..", "..", "tests"));
20+
var solutionPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(assemblyPath), "..", "..", "..", "..", ".."));
21+
Console.Write("Building...");
22+
await RunDotnetAsync("build -c Release", solutionPath);
2123

2224
Console.Write("Running tests");
23-
25+
var testsPath = Path.Combine(solutionPath, "tests");
2426
testResultPaths = (await Task.WhenAll(Directory.GetDirectories(testsPath)
2527
.Where(x => x[0] != '.')
2628
.Select(RunTestsAsync)))
@@ -144,7 +146,7 @@ private static async Task<string> RunTestsAsync(string testFolder)
144146

145147
while (true)
146148
{
147-
await RunXunitAsync(testFolder, outputXmlPath).ConfigureAwait(false);
149+
await RunDotnetAsync($"test -c Release --no-build --logger \"trx;LogFileName={outputXmlPath}\"", testFolder).ConfigureAwait(false);
148150
Console.Write(".");
149151
var actualOutputPath = outputDirectory.GetFiles("output*.trx").Select(x => x.FullName).FirstOrDefault();
150152
if (actualOutputPath is null)
@@ -192,18 +194,18 @@ private static (string Category, string Name, IReadOnlyDictionary<string, TestRe
192194
return ((category, name, testResults));
193195
}
194196

195-
private static Task RunXunitAsync(string testFolder, string outputXmlPath)
197+
private static Task RunDotnetAsync(string arguments, string workingDirectory)
196198
{
197199
var taskCompletionSource = new TaskCompletionSource<object>();
198200
var process = new Process
199201
{
200202
StartInfo =
201203
{
202204
FileName = "dotnet",
203-
Arguments = $"test -c Release --logger \"trx;LogFileName={outputXmlPath}\"",
205+
Arguments = arguments,
204206
CreateNoWindow = true,
205207
UseShellExecute = false,
206-
WorkingDirectory = testFolder,
208+
WorkingDirectory = workingDirectory,
207209
},
208210
EnableRaisingEvents = true,
209211
};

0 commit comments

Comments
 (0)