question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Current state of tests is not great, let's fix them

See original GitHub issue

As the title says current state of tests is not where it should be especially considering the purpose of the mutmut itself is to improve unit tests. I feel that we need to address these issues sooner rather than later since it will make maintenance much easier in the future.

  1. Current tests are more integration / end-to-end tests than unit tests
  2. Big chunk of code is not properly unit tested
  3. mutmut is not used on mutmut

Current tests are more integration / end-to-end tests than unit tests Here is the article by Michael Feathers that pretty much explains this point. Each unit test should test only one unit of the code, also no spinning disks for unit tests and no IO at all. Some parts of the code will, for sure, require refactoring to make them testable. There is a lot of IO in functions that should be moved up a level to make the code easy to test. Here is a great talk by Brandon Rhodes on how to “hoist IO”.

Big chunk of code is not properly unit tested It is hard to determine actual unit test coverage since coverage is calculated while running all tests. Currently it looks good, but there is a decent amount of edge cases that are not tested because it is hard to reproduce edge cases by writing integration tests. Coverage should be calculated when running only true unit tests.

mutmut is not used on mutmut This is the best way to make our unit tests better, that’s what mutmut does. Also this would make it easier for us to spot new use cases and potential improvements. But first, things need to be refactored.

Steps to mitigate:

  • Making a clear separation between unit tests and integration / end-to-end tests. (different dirs/files and pytestmark)
  • Stop merging pull requests that aren’t properly covered with unit tests.
  • Chunk by chunk refactor code to be testable and add appropriate unit tests for it.
  • After the old code is refactored, switch coverage to work only with unit tests.
  • Start using mutmut on unit tests

Good thing is that code base is not that big, it is a great time to do something like this. Also current tests are good for what they do, we just need to add proper unit tests.

Please let me know what you think. 😃

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
boxedcommented, Feb 2, 2019

I think we should cross that bridge when we get to it. This is a case of YAGNI. We should worry first about having solid mutations built in, and making mutmut fast and easy to use and generally improving the workflow with dealing with findings.

1reaction
boxedcommented, Jan 30, 2019

I do try to avoid classes at all costs. I agree that maybe I’ve gone too far here. What do you think about this @s-kovacevic ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
LetsGetChecked Reviews: Should you take their tests?
Does LetsGetChecked offer the right test for you? Experts review the testing options, pricing, privacy and accuracy.
Read more >
Should failing unit tests that we're not going to fix be removed?
Personally, I think keeping the tests allows you to at least understand/acknowledge some of the failing points even if you consciously choose not...
Read more >
Fix the "not wrapped in act(...)" warning - Kent C. Dodds
There are a few reasons you're getting this warning. Here's how you fix it.
Read more >
Best practices for writing unit tests - .NET - Microsoft Learn
Learn best practices for writing unit tests that drive code quality and resilience for .NET Core and .NET Standard projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found