如何从测试开始红隼? [英] How do I start kestrel from a test?
问题描述
我使用beta8建立回归测试我的ASP.NET项目5。当我设置的测试夹具我要火了红隼,这样我可以针对它运行Selenium测试,无需任何外部Web服务器。我该怎么做呢?
这基本上是这样的:
公共类RegressionTests:IDisposable接口
{ 公共RegressionTests()
{
//开始隼
} [事实]
公共无效的Test1()
{
Assert.True(真);
//更多的测试...
} 公共无效的Dispose()
{
//关闭红隼
}
}
这是我到目前为止已经试过,但我无法得到它的工作。它不拿起project.json文件。好了,说实话,我不知道该怎么传递给它,因为我找不到任何地方我可以传递给 Microsoft.AspNet.Hosting.Program
什么命令ARGS
新Microsoft.AspNet.Hosting.Program(CallContextServiceLocator.Locator.ServiceProvider)。主要(
新[]
{
- 服务器,
Microsoft.AspNet.Server.Kestrel
- 项目,
../Web/project.json
- 港口,
5001,
});
看看的的 MusicStore样品E2E测试的。他们发动所有服务器(IIS,红隼,WebListener)。
引擎盖下,他们所使用的部署在<一个href=\"https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Server.Testing/Deployers/ApplicationDeployer.cs\"相对=nofollow> Microsoft.AspNet.Server.Testing 。
I'm setting up regression testing for my ASP.NET 5 project using beta8. When I setup the test fixtures I want to fire up kestrel so that I could run selenium tests against it without the need for any external web server. How do I do this?
It's basically something like this:
public class RegressionTests : IDisposable
{
public RegressionTests()
{
// Start kestrel
}
[Fact]
public void Test1()
{
Assert.True(true);
// more tests...
}
public void Dispose()
{
// Shutdown kestrel
}
}
This is what I've tried so far but I couldn't get it to work. It doesn't pick up the project.json file. Well, to be honest, I don't know what to pass to it since I can't find anywhere what command args I can pass to Microsoft.AspNet.Hosting.Program
.
new Microsoft.AspNet.Hosting.Program(CallContextServiceLocator.Locator.ServiceProvider).Main(
new[]
{
"--server",
"Microsoft.AspNet.Server.Kestrel",
"--project",
"../Web/project.json",
"--port",
"5001",
});
Take a look at the MusicStore sample E2E Tests. They launch all servers (IIS, Kestrel, WebListener).
Under the hood, they use the deployer in Microsoft.AspNet.Server.Testing.
这篇关于如何从测试开始红隼?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!