-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify currently executing test in the Test Explorer #3637
Comments
Hmm. One thing is that the unit tests are supposed to be isolated and self-contained. Therefore, it should not matter what order you run them in. It makes sense for a module to do a setup (that'd be where you'd initialize the mocks, etc.) so that all methods have a "context" to run in but after that, it should be basically self-contained and not matter what order. Furthermore, the typical thing to do when the context is invalid due to external factor is to make the tests inconclusive. In other words, the test should have only one reason to fail; and it should not fail if the context isn't valid. That's some other test's responsibility. Otherwise, you'd get a mess of failed tests and no idea what went wrong. |
This goes against one of the principles of unit testing, or encourages having tests that depend on each other - good tests are isolated and don't depend on the outcome of other tests, so the order in which tests are executed should be utterly irrelevant. As for cancelling... that's not quite possible. See #274 - we need to fire up a command in the VBIDE UI, but then, the tests are running on that thread (the only thread they can ever run on), so I've no idea how to go about this. |
@bclothier I totally agree that tests should be able to run isolated and that's the way I'm building them. Here's an argument for knowing which tests are running: With referential integrity enabled, the ACE engine can cascade updates and deletes to other tables with a simple query. However, if that query fails for any reason it will leave the database in an inconsistent state (orphaned records etc). In order to suppress Access' warnings about appending records etc causing message boxes to appear every time a query is run, we issue a DoCmd.SetWarnings False, run the queries, then DoCmd.SetWarnings True. In that scenario, a failed query doesn't give any indication that something went wrong but fails silently. I need to know if a query fails and without knowing which query is running, there's no way to trace why the database is inconsistent. I haven't seen any way to mock a query run such that I can trap errors without also enabling all the warnings dialog boxes. If you can think of a way to do that, I'd be very interested to learn how. The only way I can think of to do it is to '@ignoretest all tests that run any query and enable them one at a time - rerunning all tests (which takes a while on my very complex database) and examine the state of the tables. That would be a very painful way to figure out which query is not behaving properly. That's why knowing which test is running or at least tracing the order in which they are run could provide insight into where the problem lies. The only alternative I can think of is to run the SQL in VBA and test that way but that causes a HUGE performance penalty because ACE can compile a query and reuse it rather than compiling it every time the VBA SQL is run. Feedback is very welcome. Oh, and by the way - you guys are really great at responding quickly - thanks for that! |
Oh, knowing which test is running is an entirely different problem - and completely feasible! Great suggestion! |
@BitSprocket Addressing your other questions -- I appreciate the difficulty you might be having here because those are not easily mockable and in reality, we should be abstracting the result of queries so that's there's no database. This blog may be of help in illustrating. That said, I see few options here that would get you set up fairly quickly:
|
@bclothier Those are great suggestions.
|
Regarding the request for source RE: performance of compiled query -- I do not have the whitepaper directly and Microsoft has made it hard to find old whitepapers but there is a quotation here that recommends executing dynamic SQL to optimize the query at runtime. As for |
@bclothier Caveat: if Access doesn't support nested transactions, |
@bclothier From the article you posted:
Well, that changes things doesn't it? Now I have to rethink my query strategy... |
@retailcoder actually it depends on the source. For an Access backend source, nested transactions are possible. For an ODBC source, it's not supported. But for unit testing, we shouldn't be dealing with external data source; only a temporary local database. No need to involve network errors in those tests. @BitSprocket FWIW - if you still want to parameterize, you might be able to get it with ADO instead of DAO. But TBH, I almost never use ADO w/ Access sources; only external sources generally and I don't know if ADO would give you any better performance with parameters than DAO. I doubt so, since you're still relying on the Access optimizer which isn't quite as sophisticated as SQL Server's is. |
FWIW, we have an attribute to ignore tests. |
😉 I'm going to re-purpose this issue in a minute. |
Let's make the test engine instruct the test explorer to toggle some "running" test status (perhaps display it with some arrow icon) just before invoking a test method. The challenge will likely be to get the UI to repaint correctly before the test is actually running. |
It would be great to be able to determine the order in which test are run. Better yet, specifying the order would allow for devs to push known failing tests (i.e. methods that haven't been implemented yet but their tests have) to the end of the run.
Additionally (and this might be another thread) it would be very useful to be able to stop the test run if something goes off the rails right away such as having an invalid initial state in the host. I am developing in Access and sometimes table links are broken for various reasons (for example.)
Thoughts?
The text was updated successfully, but these errors were encountered: