How to implement customize output for pact?
See original GitHub issueHi Brother,
How to implement customize output for PactVerifierConfig , currently i use NUnit test framework in out project , and i want to output the pact test result in unit test window, but it didn’t work , can you give some demo code to handle it , thanks .
currently code as bellow:
`
const string serviceUri = "http://localhost:51502";
var config = new PactVerifierConfig
{
Outputters = new List<IOutput>
{
new ConsoleOutput()
}
};
IPactVerifier pactVerifier = new PactVerifier(config);
pactVerifier
.ServiceProvider("Event API", serviceUri)
.HonoursPactWith("Event API Consumer")
.PactUri("userclient-userservice.json")
.Verify();
}`
ConsoleOutput implementation
public class ConsoleOutput: IOutput { public void WriteLine(string line) { Console.WriteLine(line); } }
when i run the test , it will throw the exception :
PactNet.PactFailureException : Pact verification failed. See output for details. If the output is empty please provide a custom config.Outputters (IOutput) for your test framework, as we couldn't write to the console.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
5 minute guide | Pact Docs
1. Start with your model · 2. Create an Order API client · 3. Configure the mock Order API · 4. Write a...
Read more >Implementing the provider changes - PactFlow Documentation
Implementing the provider changes · Go to your PactFlow account, find the new pact on the consumer branch feat/new-field and click "VIEW PACT"....
Read more >pactFileWriteMode overwrite not working anymore in Pact
It is strongly recommended that this is set to false, as allowing modification makes the results of can-i-deploy unreliable.
Read more >PACT Space Module Design Guide
4.2 PACT Space Module Core Design Strategies ... Patient-Centric Care Room/ Equipment and Supplies at Point-of-Use/ Diagnostic. Services ... This results in.
Read more >VA extended PACT Act deadline today
The U.S. Department of Veterans Affairs extended the application deadline for veterans and survivors to apply or submit their “intent to file” ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the detailed reply.
The ConsoleOutput is registered by default, and works for most test frameworks. xUnit however redirects the stdout and therefore the default handling does not work. See https://stackoverflow.com/questions/7138935/xunit-net-does-not-capture-console-output. When using xunit you need to provide a custom outputter, not the included ConsoleOutput. If you search the readme or samples for “XUnitOutput”, you can see an example of how this is done. That should hopefully get you the details about why the exception was actually thrown.
@andreimcristof A PactFailure exception is thrown when something fails to be performed correctly, in Ken’s case the “Pact verification failed”. The “Note” part of that message is just saying that if you see no details about why the failure occurred, you may need to register a custom outputter. Not registering a custom outputter will never be the cause of an exception. The “Note” part is always written, regardless of test framework and if you have registered one or not, as we don’t know the runtime config at the time the exception is thrown. Does that make sense? Any suggestions to make this clearer?