Re:It's not what programming languages do, it's what they sh...
by kazinator on Friday March 27, 2020 @09:52AM
(#22702805)
Avoiding singletons in the app implementation will not put a dent in UI testability. If you instantiate the MainWindow as a local variable in the top-level function, and pass that object everywhere it is required as an argument, external testing of your UI is not any easier.
[ Parent
| on HN ]
Re:It's not what programming languages do, it's what they sh...
by lmm on Friday March 27, 2020 @11:43PM
(#22709039)
It's a step in the right direction, and it gives some immediate value: you can see which functions don't actually need the MainWindow and can therefore be tested conventionally (you might argue that those were never actually UI tests, but in practice you'll end up using your UI testing techniques for things that don't actually use UI if you can't tell), and you're nudged towards only passing it where it's needed; also you could try to mock or stub it, which might cover at least some of the simple cases.