Hey i have a question for the Consumer Test in Pac...
# general
a
Hey i have a question for the Consumer Test in Pactnet. While im trying to create a test, where i have a Client(auto generated by swagger) and a Service(where the logic depends). I tried to implement it like its written in the examples but it doesnt work. The service class needs some classes as parameters in the constructor (the client as well). Mocking the Service and Controller classes does not make sense in my mind. What do i miss? Or what would be the best way to do it?
m
You don't mock the logic, you mock downstream systems. If your unit test needs dependencies to instantiate your API client by all means inject those in the test. The point here is to unit test your API client, which creates a pact file. In a separate test (provider) you verify these assumptions
a
I tried this as well, but im getting this error : xUnit1041: Fixture argument 'heimdallApi' does not have a fixture source (if it comes from a collection definition, ensure the definition is in the same assembly as the test) . So im in the tests folder. And the dependencies are initialized in a modules.cs file, for using them in the src folder.
Forgot to add, that im initializing them in the Constructor and then using it in the unit test
m
I can't help with that sorry (sounds unrelated to Pact and I'm not a .NET guy). But the point is, a pact test is essentially a unit test of your API client
🙌 1
a
Still thanks:)
🙏 1