我已经在C# dotnet核心中在消费者端实现了PACT,并且我能够使用下面的代码将*.json pact文件发布到PactBrocker。
var pactPublisher = new PactPublisher("http://domain.pact.dius.com.au", new PactUriOptions("***", "***"));
pactPublisher.PublishToBroker($"..\pacts\userservice.api-event.api.json",
"1.0.2");在提供者端(同样是在C# dotnet内核中),当我使用一个单元测试用例(参见下面的代码)试图验证相同的已发布协议时:
[Fact]
public void EnsureEventApiHonoursPactWithConsumer()
{
//Arrange
// createing the "config" object
//Act / Assert
IPactVerifier pactVerifier = new PactVerifier(config);
pactVerifier
.ProviderState($"{_providerUri}/provider-states")
.ServiceProvider("Event.API", _providerUri)
.HonoursPactWith("UserService.API")
.PactUri("http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2", new PactUriOptions("***", "***")).Verify();
}当我运行这个单元测试时,我得到了低于错误的信息。
PactNet.PactFailureException : Pact验证失败。有关详细信息,请参见输出。如果输出为空,请为您的测试框架提供自定义config.Outputters (IOutput),因为我们无法将其写入控制台。在PactNet.Core.PactCoreHost
1.Start() in C:\projects\pact-net\PactNet\Core\PactCoreHost.cs:line 139 at Event.Test.EventApiTests.EnsureEventApiHonoursPactWithConsumer() in C:\POC\pact2\Event.Api\Event.Test\EventAPITests.cs:line 55 **Error reading file from** [http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2](http://domain.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2) **No connection could be made because the target machine actively** **refused it. - connect(2) for "domain.pact.dius.com.au" port 80** C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:ininitialize‘ 连接中的C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:inopen' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in块 C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:intimeout' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:inconnect‘ C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:indo\_start' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:instart‘
有人能帮我解决这个错误吗?协议代理服务器不在我的控制范围内。我从http://pact.dius.com.au/网站上得到的。
发布于 2018-10-31 09:13:51
找到答案了。我在我办公室的代理环境里。在我家很管用。另外,我需要点击https (端口443),而不是http (端口80)。
https://stackoverflow.com/questions/53028612
复制相似问题