Thoughts about unittest run order
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue May 7 17:10:28 UTC 2019
On Tue, May 07, 2019 at 04:50:23PM +0000, Atila Neves via Digitalmars-d wrote:
> On Tuesday, 7 May 2019 at 11:29:43 UTC, H. S. Teoh wrote:
> > On Tue, May 07, 2019 at 09:40:27AM +0000, Atila Neves via Digitalmars-d
> > wrote: [...]
> > > If the order tests run in is important, the tests are coupled...
> > > friends don't let friends couple their tests.
> >
> > How do you decouple the tests of two functions F and G in which F
> > calls G?
>
> It depends. If F and G are both public functions that are part of the
> API, then one can't. Otherwise I'd just test F since G is an
> implementation detail.
>
> I consider keeping tests around for implementation details an
> anti-pattern. Sometimes it's useful to write the tests if doing TDD
> or debugging, but afterwards I delete them.
I almost never delete unittests. IME, they usually wind up catching a
regression that would've been missed otherwise.
T
--
If you want to solve a problem, you need to address its root cause, not just its symptoms. Otherwise it's like treating cancer with Tylenol...
More information about the Digitalmars-d
mailing list