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

(Help wanted!) More and more tests! #36

Open
mauricioaniche opened this issue Feb 13, 2020 · 4 comments
Open

(Help wanted!) More and more tests! #36

mauricioaniche opened this issue Feb 13, 2020 · 4 comments

Comments

@mauricioaniche
Copy link
Owner

CK is a simple tool; yet, people's code are complicated!! Although our test suite has been growing, there are always exceptional cases that might lead the tool to bring strange results.

If you are looking for a way to start contributing to this project, I suggest you to write tests!! Our test suite is full of examples! In practice, all you need to do is:

  • Create a "fake" class with the property you want to assert, e.g., does CK calculate WMC well when we have a ternary if in the code? This code goes to the /fixture folder
  • Feel free to either add your test to an existing one (e.g., if you are adding one more test for the WMC metric, this method should be in the WMCTest class) or add a new file (e.g., you are testing a more holistic behaviour, and this behaviour does not depend on a single metric)
  • Write a test that executes CK in the folder that contains your fixture.
  • Write good assertions! Try to assert as much as possible. Good assertions are key! A good one to remember is to assert the value of that metric at class and method level (we have found bugs where the metric at method-level was correct, but at class-level, there was a bug)!

Submit your tests as a PR!

If you found a bug,** THANK YOU**! Feel free to fix it yourself! If you can't, no worries. Just open an issue, and I'll work on that!

@mauricioaniche mauricioaniche changed the title More and more tests! (Help wanted!) More and more tests! Feb 13, 2020
@mauricioaniche
Copy link
Owner Author

The RFC metric is one that deserves a lot more tests!

@maykon-oliveira
Copy link
Contributor

maykon-oliveira commented Apr 24, 2020

I have a question,
should be method reference counted in RFC metric?

Map<Character, List<Integer>> byAlphabet =
        aList.stream()
            .collect(
                Collectors.groupingBy(
                    e -> new Character(e.getName().charAt(0)),
                    Collectors.mapping(Avatar::getId, Collectors.toList())));

For example, that's stream above, there is a method reference, but currently RFC does not include it.

So, the result of RFC metric above is 7, what should be the result 7 or 8?

RFC test file at line 82

@mauricioaniche
Copy link
Owner Author

We are probably not counting the Avatar::getId, but maybe we should! Would you mind fixing it and opening a PR?

@maykon-oliveira
Copy link
Contributor

Sure!

I opened up a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants