[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ERT: How to implement expensive initialization and cleanup?
From: |
Eli Zaretskii |
Subject: |
Re: ERT: How to implement expensive initialization and cleanup? |
Date: |
Mon, 05 Jun 2023 14:11:18 +0300 |
> Date: Sun, 4 Jun 2023 22:04:23 +0200
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
>
> Trying to write my first ERT test. For the tests I need to set up a
> GnuPG home directory from scratch, including directory creation, key
> import, and key trust management. Plus I need to clean up that mess
> after the tests have finished. Takes some 2secs on my system with all
> that process communication between Emacs and GnuPG.
Are these test files constant, i.e. do you need to create the same
files time and again each time the test is run? If so, perhaps take a
look at ert-resource-directory and its friends in ert-x.el. You will
see in our test suite several examples of tests that use such constant
data. Data that is the same in all tests is better made part of the
test suite, so it doesn't need to be generated as part of running the
test.
> The cleanest solution would be to do that for every test, but that would
> get expensive if I go for many small tests, which seems to be better in
> terms of diagnosability.
I wouldn't worry about performance too much in this case. Don't
forget that an important feature of the test suite is to be able to
run each test in the FOO-tests.el file individually. So you'll need
to allow per-test initialization anyway.