Skip to content
DevMeme
5049 of 7590
Testing Post #5528 · source on Telegram

How to Achieve 100% Code Coverage with Zero Effort

Description

This is a two-panel meme that humorously critiques the software development metric of code coverage. The top panel displays a screenshot of a code editor with a JavaScript unit test. The code imports 'expect' from 'chai' and 'mocha', and defines a single test case: 'it("Should equal 0", () => { expect(0).to.equal(0); });'. This test is a tautology, as it only asserts that the number 0 is equal to itself, providing no value in verifying actual application logic. The bottom panel uses the 'Skyrim 100' meme format, showing a skill progress bar from the video game The Elder Scrolls V: Skyrim, with the text 'Code Coverage 100' prominently displayed. The joke is that by writing such useless, tautological tests, a developer can artificially inflate their code coverage metrics to 100% to satisfy project requirements or automated quality gates, without actually improving the quality or reliability of the software

Comments

14
Anonymous ★ Top Pick Management wanted 100% test coverage, so I gave them 100% test coverage. They never specified the tests had to actually *test* anything
  1. Anonymous ★ Top Pick

    Management wanted 100% test coverage, so I gave them 100% test coverage. They never specified the tests had to actually *test* anything

  2. Anonymous

    Just hit 100% coverage with `expect(0).to.equal(0)` - SonarQube’s ecstatic, the board’s impressed, and the mutation tests just handed in their resignation

  3. Anonymous

    After 15 years of watching teams celebrate 100% coverage while production burns, I've learned that 'expect(0).to.equal(0)' has the same coverage impact as actual integration tests but takes 1000x less time to write - which explains why our Q4 metrics look fantastic and our on-call rotation looks like a war crime

  4. Anonymous

    Ah yes, the classic 'expect(0).to.equal(0)' test - because nothing says 'production-ready' like verifying that JavaScript's type system hasn't fundamentally collapsed since the last CI run. This is the testing equivalent of a load-bearing comment: technically it increases your coverage metric, satisfies that arbitrary 80% threshold your architect mandated, and gives you just enough plausible deniability when the actual business logic explodes in production. Bonus points if this test is the reason your team celebrates hitting 100% coverage in the sprint retrospective while the bug backlog grows exponentially

  5. Anonymous

    100% coverage achieved: because asserting 0==0 scales better than any integration suite ever will

  6. Anonymous

    100% coverage, 0% mutation score - the perfect KPI for confidence theater

  7. Anonymous

    OKR unlocked: 100% code coverage via a Mocha/Chai test asserting 0 === 0 while importing every module - turns out we’re testing the metric, not the software

  8. @mihanizzm 2y

    Explanation brigada plz

    1. @vladyslav_google 2y

      0 === 0, this suite just compares static numbers and not the functionality of the application itself

      1. @Sp1cyP3pp3r 2y

        Didn't ponyal

        1. @pcfighter 2y

          Sometimes you have to do unit tests for every function you have in app. If you don’t do it one, code won’t be covered in 100%.

          1. @Sp1cyP3pp3r 2y

            Damn

        2. @Denfox48 2y

          Srazu vidno - svoy chelovek

  9. @WaterCat73 2y

    Import names are ochen interesniy

Use J and K for navigation