Extend timeout and enforce usings (#12952)

Extend timeout and enforce usings
This commit is contained in:
Ryan Brandenburg 2019-08-09 13:38:09 -07:00 committed by GitHub
parent b1fdf27f61
commit 3ab8ebff42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View File

@ -45,7 +45,7 @@ namespace Templates.Test.SpaTemplateTest
{
Project = await ProjectFactory.GetOrCreateProject(key, Output);
var createResult = await Project.RunDotNetNewAsync(template, auth: usesAuth ? "Individual" : null, language: null, useLocalDb);
using var createResult = await Project.RunDotNetNewAsync(template, auth: usesAuth ? "Individual" : null, language: null, useLocalDb);
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", Project, createResult));
// We shouldn't have to do the NPM restore in tests because it should happen
@ -61,26 +61,26 @@ namespace Templates.Test.SpaTemplateTest
Assert.Contains(".db", projectFileContents);
}
var npmRestoreResult = await Project.RestoreWithRetryAsync(Output, clientAppSubdirPath);
using var npmRestoreResult = await Project.RestoreWithRetryAsync(Output, clientAppSubdirPath);
Assert.True(0 == npmRestoreResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm restore", Project, npmRestoreResult));
var lintResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run lint");
using var lintResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run lint");
Assert.True(0 == lintResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm run lint", Project, lintResult));
if (template == "react" || template == "reactredux")
{
var testResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run test");
using var testResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run test");
Assert.True(0 == testResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm run test", Project, testResult));
}
var publishResult = await Project.RunDotNetPublishAsync();
using var publishResult = await Project.RunDotNetPublishAsync();
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));
// Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release
// The output from publish will go into bin/Release/netcoreapp3.0/publish and won't be affected by calling build
// later, while the opposite is not true.
var buildResult = await Project.RunDotNetBuildAsync();
using var buildResult = await Project.RunDotNetBuildAsync();
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
// localdb is not installed on the CI machines, so skip it.
@ -88,13 +88,13 @@ namespace Templates.Test.SpaTemplateTest
if (usesAuth)
{
var migrationsResult = await Project.RunDotNetEfCreateMigrationAsync(template);
using var migrationsResult = await Project.RunDotNetEfCreateMigrationAsync(template);
Assert.True(0 == migrationsResult.ExitCode, ErrorMessages.GetFailedProcessMessage("run EF migrations", Project, migrationsResult));
Project.AssertEmptyMigration(template);
if (shouldVisitFetchData)
{
var dbUpdateResult = await Project.RunDotNetEfUpdateDatabaseAsync();
using var dbUpdateResult = await Project.RunDotNetEfUpdateDatabaseAsync();
Assert.True(0 == dbUpdateResult.ExitCode, ErrorMessages.GetFailedProcessMessage("update database", Project, dbUpdateResult));
}
}
@ -247,7 +247,7 @@ namespace Templates.Test.SpaTemplateTest
browser.Equal("Weather forecast", () => browser.FindElement(By.TagName("h1")).Text);
// Asynchronously loads and displays the table of weather forecasts
browser.Exists(By.CssSelector("table>tbody>tr"));
browser.Exists(By.CssSelector("table>tbody>tr"), TimeSpan.FromSeconds(10));
browser.Equal(5, () => browser.FindElements(By.CssSelector("p+table>tbody>tr")).Count);
}

View File

@ -42,7 +42,10 @@ namespace Microsoft.AspNetCore.E2ETesting
=> WaitAssertCore(driver, () => Assert.Single(actualValues()));
public static void Exists(this IWebDriver driver, By finder)
=> WaitAssertCore(driver, () => Assert.NotEmpty(driver.FindElements(finder)));
=> Exists(driver, finder, default);
public static void Exists(this IWebDriver driver, By finder, TimeSpan timeout)
=> WaitAssertCore(driver, () => Assert.NotEmpty(driver.FindElements(finder)), timeout);
private static void WaitAssertCore(IWebDriver driver, Action assertion, TimeSpan timeout = default)
{