kowainik / hit-on

:octocat: Kowainik Git Workflow Helper Tool
https://kowainik.github.io/projects/hit-on
Mozilla Public License 2.0
76 stars 13 forks source link

Implement unit tests for `parseOwnerRepo` function #35

Closed chshersh closed 5 years ago

chshersh commented 5 years ago

This function:

https://github.com/kowainik/hit-on/blob/4f8d392967675f535232ec9d407dae227f1bcf73/src/Hit/Issue.hs#L98

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

StevenXL commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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

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 commented 5 years ago

@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.