aeson icon indicating copy to clipboard operation
aeson copied to clipboard

Question: adding a test, how-to?

Open EncodePanda opened this issue 3 years ago • 2 comments

I think I found a bug in Aeson. I want to contribute a fix. Before the fix, I want to prove that the bug exists with a failing unit test. How should do it? Should that regression test be a golden test? Some other test? Which modules I should look at first. Please advice :) I will be also happy to contribute a "How to contribute" guide for future generations to come :)

EncodePanda avatar Jun 29 '22 21:06 EncodePanda

You can add unit tests here:

https://github.com/haskell/aeson/blob/master/tests/UnitTests.hs

Many of those are in fact regression tests for previously found bugs.

  1. Define your test as an Assertion
  2. Add it to tests with testCase

There are also golden tests for error messages:

https://github.com/haskell/aeson/blob/master/tests/ErrorMessages.hs

Adding more instructions in the contributors guide is a good idea.

Lysxia avatar Jun 29 '22 22:06 Lysxia

Awesome! I will try to hack an example tomorrow. I will keep this issue open for now in case I have some questions. I will close it once the test is added and/or the contributors' guide is updated. Thanks @Lysxia

EncodePanda avatar Jun 29 '22 22:06 EncodePanda