Ste*_*ond 5 asp.net selenium asp.net-core-mvc asp.net-core
我有一个带有“web”项目(ASP.NET v5)和“web.Tests”项目(xunit.net 2.1beta)的 VS 解决方案——其中一项测试是检查呈现的页面,我正在尝试让测试自动启动站点,因此我不需要单独/手动运行它。
namespace web.Tests
{
public abstract class BrowserTest : IDisposable
{
protected readonly IisExpress server;
protected readonly IWebDriver driver;
protected BrowserTest()
{
var project = ProjectLocation.FromPath(Path.Combine(SolutionRoot, "src", "web", "wwwroot"));
var app = new WebApplication(project, 8080);
server = new IisExpress(app);
server.Start();
driver = new PhantomJSDriver();
}
public void Dispose()
{
server.Stop();
}
}
}
Run Code Online (Sandbox Code Playgroud)
服务器启动和停止正常,但是当我点击一个页面时,我得到一个 HTTP 500,带有 System.InvalidOperationException:
A type named 'StartupProduction' or 'Startup' could not be found in assembly 'web.Tests'.
如何指定我要从“web”项目而不是“web.Tests”项目运行 Startup.cs?
通过切换到 Kestrel 作为主机解决了这个问题 - 特别是因为 Kestrel 现在是 ASP.NET 5 中唯一受支持的主机
using System;
using System.Diagnostics;
using System.IO;
using OpenQA.Selenium;
using OpenQA.Selenium.PhantomJS;
namespace Test
{
public abstract class PhantomFixture : IDisposable
{
public readonly IWebDriver driver;
private readonly Process server;
protected PhantomFixture()
{
server = Process.Start(new ProcessStartInfo
{
FileName = "dnx.exe",
Arguments = "web",
WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), "..", "Web")
});
driver = new PhantomJSDriver();
}
public void Dispose()
{
server.Kill();
driver.Dispose();
}
}
}
Run Code Online (Sandbox Code Playgroud)
(显然将参数替换为Path.Combine(...)您的网络应用程序所在的位置)
| 归档时间: |
|
| 查看次数: |
1812 次 |
| 最近记录: |