Combine tests to significantly reduce runtime
This commit is contained in:
parent
9cf79dcc1a
commit
2a7e6719a4
|
|
@ -21,57 +21,27 @@ namespace AspNetCoreSdkTests
|
|||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Current))]
|
||||
public void Restore(Template template, NuGetConfig nuGetConfig)
|
||||
public void RestoreBuildRunPublish(Template template, NuGetConfig nuGetConfig)
|
||||
{
|
||||
using (var context = new DotNetContext())
|
||||
{
|
||||
context.New(template);
|
||||
context.Restore(nuGetConfig);
|
||||
|
||||
context.Restore(nuGetConfig);
|
||||
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, context.GetObjFiles());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Current))]
|
||||
public void Build(Template template, NuGetConfig nuGetConfig)
|
||||
{
|
||||
using (var context = new DotNetContext())
|
||||
{
|
||||
context.New(template);
|
||||
context.Restore(nuGetConfig);
|
||||
context.Build();
|
||||
|
||||
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterBuild, context.GetObjFiles());
|
||||
CollectionAssert.AreEquivalent(template.ExpectedBinFilesAfterBuild, context.GetBinFiles());
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.CurrentWebApplications))]
|
||||
public void Run(Template template, NuGetConfig nuGetConfig)
|
||||
{
|
||||
using (var context = new DotNetContext())
|
||||
{
|
||||
context.New(template);
|
||||
context.Restore(nuGetConfig);
|
||||
var (httpUrl, httpsUrl) = context.Run();
|
||||
if (template.Type == TemplateType.WebApplication)
|
||||
{
|
||||
var (httpUrl, httpsUrl) = context.Run();
|
||||
Assert.AreEqual(HttpStatusCode.OK, GetAsync(new Uri(new Uri(httpUrl), template.RelativeUrl)).StatusCode);
|
||||
Assert.AreEqual(HttpStatusCode.OK, GetAsync(new Uri(new Uri(httpsUrl), template.RelativeUrl)).StatusCode);
|
||||
}
|
||||
|
||||
Assert.AreEqual(HttpStatusCode.OK, GetAsync(new Uri(new Uri(httpUrl), template.RelativeUrl)).StatusCode);
|
||||
Assert.AreEqual(HttpStatusCode.OK, GetAsync(new Uri(new Uri(httpsUrl), template.RelativeUrl)).StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Current))]
|
||||
public void Publish(Template template, NuGetConfig nuGetConfig)
|
||||
{
|
||||
using (var context = new DotNetContext())
|
||||
{
|
||||
context.New(template);
|
||||
context.Restore(nuGetConfig);
|
||||
context.Publish();
|
||||
|
||||
CollectionAssert.AreEquivalent(template.ExpectedFilesAfterPublish, context.GetPublishFiles());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,11 +38,5 @@ namespace AspNetCoreSdkTests.Templates
|
|||
d);
|
||||
|
||||
public static IEnumerable<TestCaseData> Current => IgnoreRazorClassLibEmpty;
|
||||
|
||||
public static IEnumerable<TestCaseData> CurrentWebApplications { get; } =
|
||||
from d in Current
|
||||
where ((Template)d.Arguments[0]).Type == TemplateType.WebApplication
|
||||
select d;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ namespace AspNetCoreSdkTests.Util
|
|||
public static (Process Process, ConcurrentStringBuilder OutputBuilder, ConcurrentStringBuilder ErrorBuilder) Run(string workingDirectory)
|
||||
{
|
||||
// Bind to dynamic port 0 to avoid port conflicts during parallel tests
|
||||
return StartDotNet("run --no-restore --urls http://127.0.0.1:0;https://127.0.0.1:0", workingDirectory, GetEnvironment(workingDirectory));
|
||||
return StartDotNet("run --no-build --urls http://127.0.0.1:0;https://127.0.0.1:0", workingDirectory, GetEnvironment(workingDirectory));
|
||||
}
|
||||
|
||||
public static string Publish(string workingDirectory)
|
||||
{
|
||||
return RunDotNet($"publish --no-restore -o {PublishOutput}", workingDirectory, GetEnvironment(workingDirectory));
|
||||
return RunDotNet($"publish --no-build -o {PublishOutput}", workingDirectory, GetEnvironment(workingDirectory));
|
||||
}
|
||||
|
||||
private static string RunDotNet(string arguments, string workingDirectory,
|
||||
|
|
|
|||
Loading…
Reference in New Issue