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

[RFC] Laws property-based tests for LogAction #2

Open
2 tasks
chshersh opened this issue May 3, 2019 · 1 comment
Open
2 tasks

[RFC] Laws property-based tests for LogAction #2

chshersh opened this issue May 3, 2019 · 1 comment
Labels
good first issue Good for newcomers test Unit testing, property testing, doctests

Comments

@chshersh
Copy link
Contributor

chshersh commented May 3, 2019

It would be really nice to have tests for the logging functionality, especially property-based testing. However, it's not really clear how to test it. It would be really nice though to have property-based tests for laws for every data type. However, in order to do this, we need to implement the following two pieces:

  • Question 1: Some way to generate arbitrary LogAction
  • Question 2: Some way to compare LogAction

Question 1 is still open. For Question 2: instead of comparing LogActions we can compare results of PureLogger.

We have doctest for unit testing, so this should be enough in terms of unit tests (though, more functions always can be covered with doctest). But having property-based tests for laws would be really good.

Any thoughts are appreciated!

@chshersh
Copy link
Contributor Author

chshersh commented May 3, 2019

Nice and convenient solution for Question 2: implement the following orphan instance in the test modules

instance (Eq msg, m ~ PureLogger msg) => Eq (LogAction m msg)

With this instance it will be very easy to compare two LogActions.

In order to test we also need to implement Show instance. We can use the same approach:

instance (Show msg, m ~ PureLogger msg) => Show (LogAction m msg)

This instance will run PureLogger and show all messages as a list.

@chshersh chshersh transferred this issue from co-log/co-log Oct 1, 2021
@vrom911 vrom911 added the test Unit testing, property testing, doctests label Oct 7, 2021
@chshersh chshersh added the good first issue Good for newcomers label Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers test Unit testing, property testing, doctests
Projects
None yet
Development

No branches or pull requests

2 participants