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

Enhancement/add tests #582

Merged
merged 19 commits into from
Jun 30, 2021
Merged

Enhancement/add tests #582

merged 19 commits into from
Jun 30, 2021

Conversation

henriquecbuss
Copy link
Member

What issue does this PR close

Closes #535

Changes Proposed ( a list of new changes introduced by this PR)

  • Layout initial testing structure
  • Add elm-test to our pre-push hook
  • Add elm-test to our CI/CD pipeline on github
  • Create examples of how to test with elm-test
  • Create some helper functions for testing
  • Define a baseline for what tests should look like and how they should be organized in our project
  • Introduce some tests for already-existing modules/functions

Note: This PR might not cover every single thing that needs testing right now. It's meant to cover some things, and establish examples for future us to use as a reference. This PR adds many tests, but only because we didn't have any tests, so this should be an exception! In order to maintain tests up to date, pull requests after this one should introduce tests alongside their enhancements/features/bug-fixes

How to test ( a list of instructions on how to test this PR)

Well, we can't write tests for tests 😅, so look over the overall structure and organization, check if you agree with it or if we could improve on something. Check if the tests make sense, cover the functions appropriately, and actually pass. Tests should be run on github alongside our other checks, like elm-review and build. The actual code of the app shouldn't change (too much), which means we're not really risking breaking the app with this PR

Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I like it how you are focusing on testing functions with business rules instead of screen flows! +1

@henriquecbuss henriquecbuss marked this pull request as ready for review June 29, 2021 23:05
Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧫

makeInput url =
{ url = url, environment = Flags.Production }
in
describe "when environment is production"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!!

@@ -0,0 +1,130 @@
module TestHelpers.Fuzz exposing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm curious, where the name fuzz comes from? i've seen "factory" "mocker" "faker" etc, but never fuzz 🤔

maybe i didn't catch the ideia but this is the same concept as those other names right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two answers for you:

Why I chose this name:
Basically to follow the names from the test package. You can see there's TestHelpers.Random, TestHelpers.Shrink and TestHelpers.Fuzz, which then are imported with the aliases Random, Shrink and Fuzz respectively, which are the same names you would use if you were to use the test package directly. These modules just provide Generators, Shrinkers and Fuzzers that are specific to our project.

Why it's named like this on the test package:
Probably because of Fuzzing (or fuzz tests), as described in the Test.fuzz documentation, which also mentions other ways this kind of test is called.

(By the way, there's a pretty interesting text about shrinkers here, explaining what they are and how they can help us)

@henriquecbuss henriquecbuss merged commit 7dd4ded into master Jun 30, 2021
@henriquecbuss henriquecbuss deleted the enhancement/add-tests branch June 30, 2021 12:56
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

Successfully merging this pull request may close these issues.

Use automated tests
2 participants