Skip to content
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

How to test bad behaviour #142

Open
lud-wj opened this issue Jun 17, 2023 · 2 comments
Open

How to test bad behaviour #142

lud-wj opened this issue Jun 17, 2023 · 2 comments

Comments

@lud-wj
Copy link

lud-wj commented Jun 17, 2023

Suppose I have a GenServer that calls a callback module implementing some behaviour.

I want to test that my GenServer does the right thing when the module does not return expected values. But hammox will not let me badly implement a behaviour.

Is there a way to opt-out type checking for a mock ?

@fuelen
Copy link

fuelen commented Jul 4, 2023

If an implementation of the behaviour raises an exception, then it should be possible to raise it using hammox.
If an implementation returns a bad value, then it is better to have a separate set of tests which ensures that the implementation returns only expected data.

@lud-wj
Copy link
Author

lud-wj commented Jul 4, 2023

The goal here is not to test the implementations, but how the code that is calling the implementations reacts when the implementation is not correct.

For instance you may want to just log an error, or to fallback to a specific action, or just crash.

I can just define an implementation module in the test, but it's cool to be able to mock just one function. I just used Mox for that specific case. But what could be cool is to be able to tell to ignore spec checks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants