Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 60

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 66

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 72

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 76

Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 56

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 578

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 585

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 606

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 613

Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 620

Warning: Cannot modify header information - headers already sent by (output started at /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php:545) in /srv/sidawson.com/public/htdocs/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1544

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/core.php on line 1092

Warning: Cannot modify header information - headers already sent by (output started at /srv/sidawson.com/public/htdocs/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php:545) in /srv/sidawson.com/public/htdocs/wp-includes/feed-rss2-comments.php on line 8
Comments on: Unit Testing – Necessary, but Not Enough https://sidawson.com/2008/07/unit-testing-necessary-but-not-enough.html Coding; trickery; magic Fri, 04 Jul 2008 18:23:21 +0000 hourly 1 https://wordpress.org/?v=6.4.5 By: Si Dawson https://sidawson.com/2008/07/unit-testing-necessary-but-not-enough.html/comment-page-1#comment-15 Fri, 04 Jul 2008 18:23:21 +0000 http://sidawson.com/?p=6#comment-15 In reply to Christine D..

a couple of my testing rigs depend on conditional compilation code which is internal – it's pretty much necessary to access all the internal variables. And the overall code is so complex that without that you'd never know what was wrong.

I suppose, thinking about it, you could just wrap all the header declarations with conditional statements – then change the compile flags every time you tested.

You're right though, it's ugly & impure.

]]>
By: Christine D. https://sidawson.com/2008/07/unit-testing-necessary-but-not-enough.html/comment-page-1#comment-14 Fri, 04 Jul 2008 18:05:04 +0000 http://sidawson.com/?p=6#comment-14 In reply to Si Dawson.

The accessibility thing bothers me, too. Someone needs to hack our respective languages and create a new accessibility modifier for “public, but only for testing robots. Otherwise private”.

(I suppose an alternative would be to have unit tests living in the same class as the code they are testing. I dislike it in an architectural purity kind of way d: )

]]>
By: Si Dawson https://sidawson.com/2008/07/unit-testing-necessary-but-not-enough.html/comment-page-1#comment-13 Fri, 04 Jul 2008 06:56:18 +0000 http://sidawson.com/?p=6#comment-13 In reply to Christine D..

Yep, I completely agree.

I'm definitely in the “unit testing is a must” camp now. I'm just not sure they're enough

However, I am finding, even going back and writing tests afterwards, that it's making me double (and triple) check all of my logic. Plus, as you point out, tidying up everything at the bottom of the stack, and rethinking flow. It's kindof an enforced code review – which is always helpful.

The only thing I dislike is the requirement to expose so much of the interface in order to test things thoroughly. There's a stack of private methods that are really only pertinent to the inside of any given module that shouldn't be exposed.. and yet have to be. But it's a minor gripe really – particularly considering how sloppy my architecture is generally :)

]]>
By: Christine D. https://sidawson.com/2008/07/unit-testing-necessary-but-not-enough.html/comment-page-1#comment-12 Fri, 04 Jul 2008 01:04:06 +0000 http://sidawson.com/?p=6#comment-12 At the very least, code that I write which is unit tested is written in a way which is much clearer than code that isn't – if I can't easily test something, just about every time it's because there's a better way to organise things.

(And, well, I like the happy green lights that unit testing tools inevitably show up when everything is working properly <: )

Unit tests, at least, can help you make sure that the little details at the bottom keep on doing what they're supposed to / unit tests which *could* be testing the wrong thing are probably trying to test too much.

]]>