You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unit test infrastructure that attempts to ease authoring of tests, but encourages bad programming practices are Bad. I used to not realize this, and am as guilty as anyone of propogating bad behavior.
This was highlighted when I discovered that in v1 and early v2 Application.Run was disposing the Toplevel:
Moving forward I want us to be more hard core about this, and not letting any example code (Scenarios) or unit tests act badly. For the most part, the Scenarios have already been fixed because UI Catalog verifies things via DEBUG_IDISPOSABLE.
However, there are dozens of unit tests that are still coded slopily/incorrectly and should be fixed. This issue is to track the fixing of them.
Step 1 - Remove the call to Application.Top?.Dispose in AutoInitShutdown.After. This will cause several dozen unit tests to fail. The fix for most of them is to simply add a top.Dispose () as the last line of the test.
Step 2 - Change SetupFakeDriver to inherit from TestRespondersDisposed (and ensure Before/After call base). This will cause even more existing unit tests to fail. Here, the fixes will involve just disposing View objects the tests create but don't dispose.
The text was updated successfully, but these errors were encountered:
Oh hey. There's an annotation for static analysis that can be used, when appropriate, to help out in tracking these down, as well as help consumers of TG with the same issue.
When set to false, disposing of the resource is not obligatory. The main use-case for explicit [MustDisposeResource(false)] annotation is to loosen the annotation for inheritors.
Unit test infrastructure that attempts to ease authoring of tests, but encourages bad programming practices are Bad. I used to not realize this, and am as guilty as anyone of propogating bad behavior.
This was highlighted when I discovered that in v1 and early v2
Application.Run
was disposing theToplevel
:Applicaton.End
leavesApplication.Top
in indeterminate state. #3313This was fixed in #3338.
Moving forward I want us to be more hard core about this, and not letting any example code (Scenarios) or unit tests act badly. For the most part, the Scenarios have already been fixed because UI Catalog verifies things via
DEBUG_IDISPOSABLE
.However, there are dozens of unit tests that are still coded slopily/incorrectly and should be fixed. This issue is to track the fixing of them.
Step 1 - Remove the call to
Application.Top?.Dispose
inAutoInitShutdown.After
. This will cause several dozen unit tests to fail. The fix for most of them is to simply add atop.Dispose ()
as the last line of the test.Step 2 - Change
SetupFakeDriver
to inherit fromTestRespondersDisposed
(and ensureBefore/After
callbase
). This will cause even more existing unit tests to fail. Here, the fixes will involve just disposingView
objects the tests create but don't dispose.The text was updated successfully, but these errors were encountered: