Unit test execution speed (how many tests per second?)

后端 未结 10 794
有刺的猬
有刺的猬 2021-02-01 05:31

What kind of execution rate do you aim for with your unit tests (# test per second)? How long is too long for an individual unit test?

I\'d be interested in knowing if

10条回答
  •  鱼传尺愫
    2021-02-01 06:27

    We're currently at 270 tests in around 3.something seconds. There are probably around 8 tests that perform file IO.

    These are run automatically upon a successful build of our libraries on every engineers machine. We have more extensive (and time consuming) smoke-testing that is done by the build machine every night, or can be started manually on an engineers machine.

    As you can see we haven't yet reached the problem of tests being too time consuming. 10 seconds for me is the point where it starts to become intrusive, when we start to approach that it'll be something we'll take a look at. We'll likely move the lower level libraries, which are more robust since they change infrequently and have few dependencies, into the nightly builds, or a configuration where they're only executed by the build machine.

    If you find it's taking more than a few seconds to run a hundred or so tests you may need to examine what you are classifying as a unit test and whether it would be better treated as a smoke test.

    your mileage will obviously be highly variable depending on your area of development.

提交回复
热议问题