DiUS / pact-workshop-dotnet-core-v3

Apache License 2.0
24 stars 25 forks source link

States and Tests not printed in logs #1

Open hwilliams-bod opened 3 years ago

hwilliams-bod commented 3 years ago

Probably a simple config issue but, while following the workshop, https://github.com/DiUS/pact-workshop-dotnet-core-v3/ , when I execute provider verification tests, state and test information is not logged.

Instead of seeing the documented

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Verifying a pact between ApiClient and ProductService
  Given no products exist
  Given product with ID 10 exists
  Given product with ID 10 exists
  Given product with ID 11 does not exist
  Given products exist
  A valid request for all products ...

Failures:

1) Verifying a pact between ApiClient and ProductService Given product with ID 10 exists - A request for a product with no auth token provided returns a response which
    1.1) has status code 401
           expected 401 but was 200

There were 1 pact failures

[xUnit.net 00:00:01.08]     tests.ProductTest.EnsureProviderApiHonoursPactWithConsumer [FAIL]
  Failed tests.ProductTest.EnsureProviderApiHonoursPactWithConsumer [425 ms]
  Error Message:
   PactNet.PactFailureException : The verification process failed, see output for errors ...

All I see is

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.95]     tests.ProductTest.EnsureProviderApiHonoursPactWithConsumer [FAIL]
  Failed tests.ProductTest.EnsureProviderApiHonoursPactWithConsumer [276 ms]
  Error Message:
   PactNet.PactFailureException : The verification process failed, see output for errors ...
mefellows commented 3 years ago

Thanks, this is currently a known issue that must be fixed prior to the next major release of Pact .NET. If you run on a non-Windows environment or in a *nix like shell, you may get that output.

MaciejReszotnik commented 2 years ago

Yes, I have the same issue when running PactNet on Windows machine. Even the tutorial does not work correctly. I am at a loss what to do since I declare custom outputters but no legit output is produced.

mefellows commented 2 years ago

This tutorial is way out of date folks - I've made a note on the readme. It's not an official one, I'd really suggest using the examples in the Pact NET repository for now. Logging is fixed in a latter version of the library.

MaciejReszotnik commented 2 years ago

If that is the case may I recommend putting that information as well on PactNet's main github page because:

  1. It makes it seem as if this workshop is official since the link is under 'Documentation' section and has no tags indicating this is not officially supported project.
  2. It does not contain information that this workshop is outdated. Putting "obsolete" next to the link, or better recommending PactNet examples on the main page instead of this outdated tutorial would help others avoid the confusion.
mefellows commented 2 years ago

Yes, I didn't realise it was linked there - I'll raise an issue. Thanks Maciej!

YOU54F commented 1 year ago

Thanks for raising the issues @hwilliams-bod, they were useful in me running through this workshop in its current state, and helping fix it up.

My notes

Original workshop

  1. Needs .NET 3.1
  2. On a Mac, no folder ~/.config/NuGet/NuGet.Config
  3. For VS - package source is already added in nuget.config, where do we add a package source
  4. Step 2 - tell user to
    1. dotnet restore
    2. dotnet run
  5. Consumer pact test, tell the reader where they can find it
  6. Dotnet test needs to be run from the Consumer folder, not Consumer/src
  7. LogDir option doesn’t do anything (no logs / log level)
  8. No logs
  9. In provider/test/ should be In provider/tests
  10. Provider version is set to target .net 5 but the workshop tells you to use .net 3.1
  11. Step 5 fails unless we delete the existing pact file as not set to overwrite - The pact file could not be written
  12. Step 7 it isn’t clear that you are inserting a provider state in-between two other (you could overwrite the state and get a failure)
  13. Step 8 needs fixes here https://github.com/DiUS/pact-workshop-dotnet-core-v3/issues/2
  14. Step 9 - middleware folder exists in test, tell user what file name should be and that they should create it under the src folder of the provider
  15. Step 9 - add provider state middleware section for auth https://github.com/DiUS/pact-workshop-dotnet-core-v3/issues/3

I've managed to fix up this repo, and update to the latest packages, without changing the API as per #7 (and following that excellent PR) - Just need to work out where to home this, as I don't have write access to this repo, and I need to check what is under the pact-foundation org :) then can update all the relevant docco links

Thanks everyone for their input!