adding unit tests that take a long time
Nate Finch
nate.finch at canonical.com
Wed Apr 27 16:24:17 UTC 2016
I just wrote a test that takes ~16.5 seconds on my machine. Since we are
trying to *reduce* the time taken by tests, I think it's prudent to give
developers a way to avoid running longer tests (obviously things like the
landing bot etc should always run all the tests).
What I *don't* want is to put long tests somewhere else which requires more
thought/setup to run. So, no separate long-tests directory or anything.
Keep the tests close to the code and run in the same way we run unit
tests. This also lowers the barrier to changing older tests that also take
a long time.
I suggest we allow developers to opt out of longer running tests. This is
already supported by passing the -short flag to go test.
Then, long tests could use
if testing.Short() {
c.Skip("skipping long running test.")
}
go test will run this test, but go test -short will skip it. Sweet, easy,
devs can run go test -short over and over, and when they need to run for
landing, they can drop the -short. CI and the landing bot don't need to
change at all.
We could also do some sort of opt-in scheme with build tags, but then CI
and the landing bot would have to change to opt in, and you'd need separate
files for long tests, which is a pain, etc.
Thoughts?
-Nate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20160427/b97a263c/attachment.html>
More information about the Juju-dev
mailing list