Should you write acceptance tests for bugs?

As a developer or as a QA-engineer you found a bug in a piece of code, and you cannot fix it straight away (maybe its not an urgent one, or you do not have the knowledge or time to fix it), so what do you do? You file an issue-report and hope it will be fixed in a future sprint by someone. So far, so normal, but should you also write a test for it? I would argue yes, you should! Why?

  • to make sure the behaviour does not get worse
  • to make sure you notice when the bug is fixed accidentally as a side-effect of some other change
  • to force the developer who fixes the bug, to look at the tests
  • to have an easy and automated way of reproducing the bug
  • to be agile and do test-driven-development. Isn’t that what you want? So better start by writing tests!

You can reach this goal by writing a specific type of bug-demonstrating acceptance test. Ideally this test should to be written in a way that they pass now and will fail when the bug is fixed. So we

  • create a (acceptance) test that demonstrates the current behaviour (meaning the behaviour of the bug)
  • also write test-steps that show the expected correct behaviour, but comment them out, so they do not run
  • tag the test with the corresponding issue-number

So when the bug is fixed, the developer is forced to look at the tests, because they fail. Reading through the test-steps she can decide if the commented-out steps are what should happen and what she has implemented.

If everything is fine she will activate the correct steps, delete the bug-demonstrating-steps and un-tag the test. Ideally more tests will be added also.

On the other hand, whoever works on the bug and is aware of the tests can do the test-editing process before starting to fix the bug. So without any extra work the developer has a way to reproduce the bug over and over again just by running the tests. She can proceed with normal TDD, modifying code to make the test pass.

BTW: all the credit for coming up with that system to Phil Davis

At ownCloud that process works pretty well. See the developer manual.



要查看或添加评论,请登录

Artur Neumann的更多文章

  • Automated Black-Box Tests for System Settings of a Micro-service Application

    Automated Black-Box Tests for System Settings of a Micro-service Application

    oCIS is the new generation open source file-sync and sharing platform, built by ownCloud, who also created the ownCloud…

  • Behaviour Driven Development on Software Rewrite

    Behaviour Driven Development on Software Rewrite

    Imagine you have an application, it works great, but you need to rewrite it, maybe because the architecture is hitting…

  • Contributing to up-stream projects

    Contributing to up-stream projects

    Behat is a BDD framework for PHP and it has a Cucumber parser called Gherkin. It’s a great tool but it missed a feature…

    1 条评论
  • Are you safe enough to take risks?

    Are you safe enough to take risks?

    Company values are great, but if they are only saved away in a document they are useless. The values need to be saved…

  • Demonstrating TDD (Test-driven development) in Go

    Demonstrating TDD (Test-driven development) in Go

    TDD is the practice to write tests before code and it should reduce failure rates and defects in your software. In this…

  • Demonstrating BDD (Behavior-driven development) in Go

    Demonstrating BDD (Behavior-driven development) in Go

    In "Demonstrating TDD (Test-driven development) in Go" I've written about TDD and this time I want to demonstrate BDD…

    1 条评论
  • Organize your company the geek-way

    Organize your company the geek-way

    How do you organize your documents in your department / company / startup ? Your policies, your minutes of meetings…

    2 条评论
  • Git bisect – squash your regression bugs quicker

    Git bisect – squash your regression bugs quicker

    Git & Git bisect If you are a software developer or studying computer science or another IT subject, you probably have…

  • first 24h programming with Go

    first 24h programming with Go

    Because I had yesterday a long overlay at the airport in KL, I decided to use the time to learn a bit of programming…

  • No experience, no job!

    No experience, no job!

    In job applications the applicants are often asked about their work-experience. But how do you gain work-experience in…

社区洞察

其他会员也浏览了