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

Implement unit tests for parseOwnerRepo function #35

Closed
chshersh opened this issue Feb 5, 2019 · 6 comments
Closed

Implement unit tests for parseOwnerRepo function #35

chshersh opened this issue Feb 5, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request tests

Comments

@chshersh
Copy link
Contributor

chshersh commented Feb 5, 2019

This function:

parseOwnerRepo :: Text -> Maybe (Name Owner, Name Repo)

It would be nice to have several tests with the hspec library.

@chshersh chshersh added the tests label Feb 5, 2019
@vrom911 vrom911 added the enhancement New feature or request label Feb 24, 2019
@StevenXL
Copy link

StevenXL commented Feb 28, 2019

This is interesting. Would love to help here. I will try it out. Might ask for help as I usually skip tests. ;-(

Oops - sorry it seems like someone else is already assigned to this. Please ping me if this issue frees up.

@kahlil29
Copy link
Contributor

@StevenXL I just saw this.
I have no experience with writing tests, so if you do, I would gladly learn from you if you would like to have a go at it. Let me know 👍

@StevenXL
Copy link

@kahlil29 I will try - if I run into problems, maybe we can pair on this at some point. Will write you an updated by this Friday (I'm in U.S. Central time).

@kahlil29
Copy link
Contributor

@chshersh
To be clear, this ticket has to be implemented with hspec and quickcheck?
I was reading up some basic tutorials about hspec and it seems like they are stating desired behaviour and examples with hspec and then using quickcheck to generate and run the tests on random data sets. Correct me if I understood something wrong or if you have another way of going about this ticket.

@chshersh
Copy link
Contributor Author

@kahlil29 I can see why there is some confusion about testing libraries. In Haskell there exist at least two paradigms for testing:

  • Unit tests
  • Property tests

QuickCheck is a library for property testing (there are at least 5 different libraries for property testing). hedgehog is another library for property testing, and in our projects we use hedgehog.

hspec is a library for unit testing. However, since QuickCheck is a trendy library, hspec implemented smooth integration with QuickCheck. That's why you can use quickcheck-style property tests when using hspec.

This issue doesn't require to implement any property tests because we don't have properties for the function. Only a bunch unit tests for different cases. That's why it's enough to use only hspec.

@kahlil29
Copy link
Contributor

kahlil29 commented Jul 6, 2019

@chshersh Thanks for your patient and detailed, yet concise explanation of the types of testing and the different libraries involved. It really helped my understanding and made the implementation easier for me to do.

chshersh pushed a commit that referenced this issue Jul 8, 2019
* [#35] Implement Unit Tests for 'parseOwnerRepo' function

* Add common-options import to test-suite in cabal file, remove extra opts

* Formatting adjustments and addition of non-happy test case scenarios

- Remove LANGUAGE pragmas
- Format and arrange imports, add explicit imports
- Minor improvements
@chshersh chshersh closed this as completed Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests
Projects
None yet
Development

No branches or pull requests

4 participants