$30 off During Our Annual Pro Sale. View Details »

How to contribute to OSS with test

How to contribute to OSS with test

Kazushige Tominaga

February 21, 2018
Tweet

More Decks by Kazushige Tominaga

Other Decks in Programming

Transcript

  1. How to contribute to OSS with test
    How to contribute to OSS with test

    View Slide

  2. Kazushige Tominaga
    Kazushige Tominaga
    tooooooooomy
    Github :
    Twitter :
    creator of
    A testing library for PHP legacy products
    https://github.com/kazu9su
    https://twitter.com/tooooooooomy
    https://github.com/kazu9su/functional-tester

    View Slide

  3. Today I don't talk about...
    Today I don't talk about...
    Principle of TDD
    How important test is!
    Something like that

    View Slide

  4. Today I talk about...
    Today I talk about...
    Why do I write test?
    Process of contributing
    Points of writing test of OSS

    View Slide

  5. I write test just because I like test :)
    I write test just because I like test :)

    View Slide

  6. OK
    OK

    View Slide

  7. An example Open Source So ware
    An example Open Source So ware
    is...
    is...

    View Slide

  8. mastodon
    mastodon

    View Slide

  9. One day, I found a spec file...
    One day, I found a spec file...

    View Slide

  10. View Slide

  11. Great
    Great

    View Slide

  12. But wait,
    But wait,

    View Slide

  13. There are a lot of rules in testing world
    There are a lot of rules in testing world
    TDD
    should test all of methods
    BDD
    should test behavior
    Test only provided public methods
    included in BDD?

    View Slide

  14. What is the policy of mastodon?
    What is the policy of mastodon?

    View Slide

  15. View Slide

  16. Let's send a Pull Request!
    Let's send a Pull Request!

    View Slide

  17. View Slide

  18. What is the point?
    What is the point?
    Write test just about 1 method
    Committers can see PR easily
    Write private methods's test
    I can find out their testing style explicitly

    View Slide

  19. Let's see their reactions...
    Let's see their reactions...

    View Slide

  20. View Slide

  21. Looks like my PR perfect
    Looks like my PR perfect

    View Slide

  22. OK, so let's go ahead!
    OK, so let's go ahead!

    View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. There is no immediate harm in these tests but you should
    know that unit tests should not try to look into private
    methods or internal variables.
    The unit test must confirm the public API of the class
    works, i.e. how other code will use it.
    The internal implementation of the class is subject to
    change (refactoring).
    The perfect refactoring is when you change the code but
    don't have to touch the tests.
    With tests like these, they would also have to be modified
    if the internal implementation changes in the future.

    View Slide

  27. Finally, I could get usable
    Finally, I could get usable
    information from the author.
    information from the author.
    PR has already been merged, but don't mind :)

    View Slide

  28. I completely understand about it
    I completely understand about it

    View Slide

  29. View Slide

  30. View Slide

  31. Looks Good To Me :)
    Looks Good To Me :)

    View Slide

  32. Sample PRs
    Sample PRs
    https://github.com/tootsuite/mastodon/pull/6439
    https://github.com/tootsuite/mastodon/pull/6446
    https://github.com/tootsuite/mastodon/pull/6455
    https://github.com/tootsuite/mastodon/pull/6456
    https://github.com/tootsuite/mastodon/pull/6500

    View Slide

  33. Conclusion
    Conclusion
    Well-known OSS needs test
    Communication with committers is the most important
    Make simple, understandable PR
    Enjoy testing

    View Slide

  34. Please introduce me the OSS needs test :)
    Please introduce me the OSS needs test :)

    View Slide

  35. Thank you!
    Thank you!

    View Slide