Azure 管道绑定到本地主机以进行测试
Azure pipelines bind to localhost for tests
我正在尝试 运行 通过启动 Web 服务器并在不同进程中用 HTTP 请求访问它来在 Azure Pipelines 中进行集成测试。
我收到的错误是
System.AggregateException : One or more errors occurred. (Failed to bind to address http://127.0.0.1:49159: address already in use.)
似乎产生错误的代码是
var builder = new WebHostBuilder()
.UseUrls("http://localhost:49159")
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Configure(app =>
{
app.Run(handler);
})
.Build();
builder.Start();
我尝试了很多不同的端口,所以假设您无法绑定到 Azure Pipelines 上的本地主机。
有谁知道是否有办法实现我想用 Azure Pipelines 做的事情?
非常感谢任何帮助!
是的,这绝对有可能。也许您不止一次启动 Web 主机并且没有销毁它(即对于每个测试装置等)?
一般来说,这些是在管道中 运行 集成测试的一些可能方法:
如果您的集成测试是用 .Net 编写的,那么请考虑在单个进程中使用 WebApplicationFactory 到 运行 服务器和测试。
如果您使用不同的工具进行集成测试,
节点的 start-server-and-test module does a great job of starting your server, waiting for it to be ready and then executing tests (you can use it for .Net projects as well). Here's a sample pipeline for .Net project.
我正在尝试 运行 通过启动 Web 服务器并在不同进程中用 HTTP 请求访问它来在 Azure Pipelines 中进行集成测试。
我收到的错误是
System.AggregateException : One or more errors occurred. (Failed to bind to address http://127.0.0.1:49159: address already in use.)
似乎产生错误的代码是
var builder = new WebHostBuilder()
.UseUrls("http://localhost:49159")
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Configure(app =>
{
app.Run(handler);
})
.Build();
builder.Start();
我尝试了很多不同的端口,所以假设您无法绑定到 Azure Pipelines 上的本地主机。
有谁知道是否有办法实现我想用 Azure Pipelines 做的事情?
非常感谢任何帮助!
是的,这绝对有可能。也许您不止一次启动 Web 主机并且没有销毁它(即对于每个测试装置等)?
一般来说,这些是在管道中 运行 集成测试的一些可能方法:
如果您的集成测试是用 .Net 编写的,那么请考虑在单个进程中使用 WebApplicationFactory 到 运行 服务器和测试。
如果您使用不同的工具进行集成测试, 节点的 start-server-and-test module does a great job of starting your server, waiting for it to be ready and then executing tests (you can use it for .Net projects as well). Here's a sample pipeline for .Net project.