-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Running tests results in failure #1
Comments
Do you have the CustomerAccountClosedActivity registered in your container, so that the state machine can resolve it? |
@phatboyg Yes, the app works fine when I think if the saga activities NOT being registered we will get a DI error indicating it cannot resolve type T, for instance, here I've registered both activities used in the saga. However, I don't know how does that relates to |
The in-memory test harness doesn't have any magic behind it, and state machines where the activities are specifying using that style need to have some type of factory that can create them. I'm not sure there is a testing harness provision for that, since there isn't a way to specify the factory beyond adding it to the consume context during the saga execution. I'd have to think about it. It's definitely a limitation of the test harness. |
That looks rational. however, In this case, even when the activities have no deps, with default ctor, the test is still failing. Anyway, thanks for the time and support; still don't know why tests fail in one project and not in the other?! And there is also a situation in which a test fails when run with all the others but when runs alone, it's green. The behavior sounds strange to me. 😩 |
So, it does use the default constructor activity factory if there isn't on available on the payload context. So if your activity has a public default constructor, it should be created as part of the test. |
Dear @phatboyg
Thanks for such an amazing content around MassTransit. I am trying to write the code as you teach on MassTransit concepts here.
I run
dotnet test
on this repository and it results in failing tests:That being said, I am trying to write the sample hand-in-hand with your education stuff, hence created a repository, however the above-mentioned tests do not fail on my repository while they are almost identical to those in
Sample-Twitch
repo, but another test fails!! ( Should_cancel_order_when_account_closed ).That repository is almost identical to the one here, and I am wondering why those tests are failing? is there something missed in between about the
InMemoryHarness
?BTW, when I remove the
.Activity(x => x.OfType<CustomerAccountClosedActivity>())
from here in theOrderStateMachine
state definitions the test pass!!I will be grateful and highly appreciate if you could invest some time to answer my question 🙏
Again, many thanks for sharing your valuable knowledge with all of us.
The text was updated successfully, but these errors were encountered: