Hi
-- I'm trying to set up some SUnit tests with a fairly heavy resource. I've set up my MyTestCase with a class side 'resources' that returns "Array with: MyTestResource". MyTestResource then starts an application for me, which does a ton of DB work and takes about a minute before it becomes available. I've put that startup code in the setUp method on the instance side of MyTestResource. The app will let me know when its available, and I use that in the isAvailable method on MyTestResource. My problem is that my MyTestCase starts up, begins starting the up, runs the tests and shuts down the up before its finished starting up. Why is MyTestCase not waiting for MyTestResource to become available? How do I make it wait? I hope this is clear. Regards Dusty You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Dusty,
-- Can you show us the code you are using to test/wait until the resource is available. It may be a simple coding error that another set of eyes will catch. Lou On Tuesday, December 30, 2014 5:28:48 AM UTC-5, Dusty wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Source Code below, Hope it makes sense? ;) archiConsole is an ABT app that calls other things, sets things up and when done it has a variable "available" which it sets to true.TestResource subclass: #ArchiTestResource And the test case. TestCase subclass: #Archie2ModelAppTests On Tue, Dec 30, 2014 at 5:12 PM, Louis LaBrunda <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
Dusty, I don't see anything here that actually waits. I'm thinking you need your ArchiTestResource>>#setUp method to wait for the resource to become available before returning.
-- On Tuesday, December 30, 2014 7:41:33 AM UTC-8, Dusty wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Thanks Richard I assumed that the TestCase would wait for TestResource isAvailable to be true before running tests.I've added a wait in my TestResource setUp and it works now, actually waits. On Tue, Dec 30, 2014 at 8:49 PM, Richard Sargent <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
On Wednesday, December 31, 2014 12:13:24 AM UTC-8, Dusty wrote:
--
Here is a pretty good write up of Pharo's TestResource (search the page for that string). http://pharo.gforge.inria.fr/PBE1/PBE1ch8.html There is also this original (?) specification of TestResource. http://www.metaprog.com/downloads/TestResources.pdf The test itself definitely does not wait for the resource, on the assumption that initializing the resource is a synchronous operation that is finished before control returns to the caller.
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Dusty,
Did you solve your problem? I'd be interested how you solved it. My first shot woul be to subclass TestSuite and implement a loop that delays for another second as long as the Resource is not available. Then I'd add a timeout to this and see how far I get with it. Unfortunately, I have no idea how to integrate this nicely with the graphical test runner... It's a pity this problem is not addressed in SUnit. We had the same problem but since this was in context of an auto-starting script, we just started the Resource in our script before building a TestSuite and running it. We found it to be good enough for our purposes and I can recommend it. Joachim -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Dusty-2
We've long done things a different way. We have a TestResource subclass which does the one-time setup kind of work in #setUp. There is no reference to our subclass. However, SUnitResourceBrowserModel>>#buildResourcesOn: spots the existence of our subclass and ultimately our #setUp is called. Only after our #setUp completes does 'TestResource sunitBrowse' complete. That is invoked via Tools -> SUnit Browser -> Browse All Test Resources. However for convenience we have a launcher that does 'TestResource sunitBrowse' then brings up the SUnitBrowser.
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by jtuchel
I simply did this: so, archiConsole will make 'available' true when its finished starting up.setUp self archiConsole isNil ifTrue: [ archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart ]. [self archiConsole available] whileFalse: [ AbtTimedWait forSeconds: 5 ]. self login. self setup. On Tue, Jan 6, 2015 at 3:59 PM, Joachim Tuchel <[hidden email]> wrote: Dusty, You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
I see, thanks for sharing.
-- So you did not find a solution for the "how can a TestCase wait for the Resources to be available" - just like we did(nt). Looks very similar to what we do. Joachim Am Mittwoch, 7. Januar 2015 12:19:25 UTC+1 schrieb Dusty:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
I think this discussion is overlooking the (as perceived by me) design of SUnit. Have you seen any sign that SUnit was designed to support what you are "complaining" about? Namely, #setUp methods that haven't finished setting up by the time they return? Everything I have seen tells me that by the end of the TestResources set up, it is meant to be fully set up.
-- I will also suggest that it is likely the intent of #isAvailable was meant to be invariant, such as "it's only available on a Unix-class platform" or "SQL is installed", etc. Admittedly, that is purely a guess lacking any evidence to confirm or deny it. If you have an asynchronous process in your set up, as in Dusty's scenario, it might be perfectly reasonable to extend the common superclass with a #waitUntilAvailableButNoLongerThanSeconds: or some such method. But I would only put it in the superclass if it were needed in multiple subclasses and if I really were convinced that was the correct interpretation of #isAvailable. Otherwise, if needed for multiple resource classes, I would suggest a new subclass of TestResource to be the common superclass of your resource classes such that it provide the necessary state and wait functionality, not based on #isAvailable. On Wednesday, January 7, 2015 3:24:15 AM UTC-8, Joachim Tuchel wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Richard Graham McLeod explained that exactly. isAvailable, from his point of view, simply allows a test to run if resource is available. So its for testing the resource, and not, as I originally thought, for SUnit to wait for it to become available before proceeding with tests.On Wed, Jan 7, 2015 at 7:07 PM, Richard Sargent <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Administrator
|
Just for completeness, I am posting this excerpt from the SUnit configuration map comment.
-- TestResource class>>availableFor: defines what a resource does when a test or another resource requires it. The standard behaviour is to assert that it is available, so raising a TestFailure if it is not, but a specialised resource subclass might override this. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |