Warning: test suite not actually isolated
roger peppe
roger.peppe at canonical.com
Thu Mar 17 10:48:16 UTC 2016
On 17 March 2016 at 09:43, John Meinel <john at arbash-meinel.com> wrote:
> tl; dr: I need some help fixing our tests that are incorrectly not isolated
> from the real world.
>
> So...
>
> In investigating the bug with PatchValue and non pointer receivers, we
> realized that PatchValue calls AddCleanup. Which means that If you are
> doing:
> func ... SetUpSuite() {
> s.PatchValue(&foo, safeFoo)
> }
>
> That PatchValue gets cleaned up in the first TearDownTest().Which means that
> the isolation you thought you were adding to the *Suite* is actually
> isolated only to the first test that gets run.
>
> I have a branch of "juju/testing" that fixes it so AddCleanup can be called
> at any time. If it is called before SetUpTest(), then it adds a cleanup to
> the Suite stack, otherwise it adds it to the current Test stack.
Brilliant, thanks! I did something similar ages ago but never
had the time to fix the required tests.
More information about the Juju-dev
mailing list