SUnit TestCase not waiting for TestResource to become available

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

SUnit TestCase not waiting for TestResource to become available

Dusty-2
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Louis LaBrunda
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:
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Dusty-2
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.
Tests must run /after/ that.

The test resource.

TestResource subclass: #ArchiTestResource
    classInstanceVariableNames: ''
    instanceVariableNames: 'archiConsole '
    classVariableNames: ''
    poolDictionaries: ''!

!ArchiTestResource publicMethods !

archiConsole
    ^archiConsole!

isAvailable
    ^self archiConsole available!

setUp
    archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart.
    self assert: self archiConsole available!

tearDown
    self isAvailable ifTrue:[
    self archiConsole available: false.
    self archiConsole shutDown; closeWidget.
    ]!

username
    ^'Administrator'! !

ArchiTestResource initializeAfterLoad!

And the test case.

TestCase subclass: #Archie2ModelAppTests
    classInstanceVariableNames: ''
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''!

!Archie2ModelAppTests class publicMethods !

resources
    ^Array with: ArchiTestResource! !

!Archie2ModelAppTests publicMethods !

resource
    ^ArchiTestResource!

setUp!

tearDown!

testDummy
    self assert: (self resource isAvailable)! !

Archie2ModelAppTests initializeAfterLoad!

On Tue, Dec 30, 2014 at 5:12 PM, Louis LaBrunda <[hidden email]> wrote:
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:
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Richard Sargent
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:
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.
Tests must run /after/ that.

The test resource.

TestResource subclass: #ArchiTestResource
    classInstanceVariableNames: ''
    instanceVariableNames: 'archiConsole '
    classVariableNames: ''
    poolDictionaries: ''!

!ArchiTestResource publicMethods !

archiConsole
    ^archiConsole!

isAvailable
    ^self archiConsole available!

setUp
    archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart.
    self assert: self archiConsole available!

tearDown
    self isAvailable ifTrue:[
    self archiConsole available: false.
    self archiConsole shutDown; closeWidget.
    ]!

username
    ^'Administrator'! !

ArchiTestResource initializeAfterLoad!

And the test case.

TestCase subclass: #Archie2ModelAppTests
    classInstanceVariableNames: ''
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''!

!Archie2ModelAppTests class publicMethods !

resources
    ^Array with: ArchiTestResource! !

!Archie2ModelAppTests publicMethods !

resource
    ^ArchiTestResource!

setUp!

tearDown!

testDummy
    self assert: (self resource isAvailable)! !

Archie2ModelAppTests initializeAfterLoad!

On Tue, Dec 30, 2014 at 5:12 PM, Louis LaBrunda <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="xKonbvvJQx0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">L...@...> wrote:
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:
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="xKonbvvJQx0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-smalltalk...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="xKonbvvJQx0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-sma...@....
Visit this group at <a href="http://groups.google.com/group/va-smalltalk" target="_blank" onmousedown="this.href='http://groups.google.com/group/va-smalltalk';return true;" onclick="this.href='http://groups.google.com/group/va-smalltalk';return true;">http://groups.google.com/group/va-smalltalk.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Dusty-2
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.

Thanks again

On Tue, Dec 30, 2014 at 8:49 PM, Richard Sargent <[hidden email]> wrote:
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:
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.
Tests must run /after/ that.

The test resource.

TestResource subclass: #ArchiTestResource
    classInstanceVariableNames: ''
    instanceVariableNames: 'archiConsole '
    classVariableNames: ''
    poolDictionaries: ''!

!ArchiTestResource publicMethods !

archiConsole
    ^archiConsole!

isAvailable
    ^self archiConsole available!

setUp
    archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart.
    self assert: self archiConsole available!

tearDown
    self isAvailable ifTrue:[
    self archiConsole available: false.
    self archiConsole shutDown; closeWidget.
    ]!

username
    ^'Administrator'! !

ArchiTestResource initializeAfterLoad!

And the test case.

TestCase subclass: #Archie2ModelAppTests
    classInstanceVariableNames: ''
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''!

!Archie2ModelAppTests class publicMethods !

resources
    ^Array with: ArchiTestResource! !

!Archie2ModelAppTests publicMethods !

resource
    ^ArchiTestResource!

setUp!

tearDown!

testDummy
    self assert: (self resource isAvailable)! !

Archie2ModelAppTests initializeAfterLoad!

On Tue, Dec 30, 2014 at 5:12 PM, Louis LaBrunda <[hidden email]> wrote:
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:
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 va-smalltalk...@googlegroups.com.
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.

--
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Richard Sargent
Administrator
On Wednesday, December 31, 2014 12:13:24 AM UTC-8, Dusty wrote:
Thanks Richard

I assumed that the TestCase would wait for TestResource isAvailable to be true before running tests.

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.

 
I've added a wait in my TestResource setUp and it works now, actually waits.

Thanks again

On Tue, Dec 30, 2014 at 8:49 PM, Richard Sargent <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QlD0qqDt6sJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">richard...@gemtalksystems.com> wrote:
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:
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.
Tests must run /after/ that.

The test resource.

TestResource subclass: #ArchiTestResource
    classInstanceVariableNames: ''
    instanceVariableNames: 'archiConsole '
    classVariableNames: ''
    poolDictionaries: ''!

!ArchiTestResource publicMethods !

archiConsole
    ^archiConsole!

isAvailable
    ^self archiConsole available!

setUp
    archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart.
    self assert: self archiConsole available!

tearDown
    self isAvailable ifTrue:[
    self archiConsole available: false.
    self archiConsole shutDown; closeWidget.
    ]!

username
    ^'Administrator'! !

ArchiTestResource initializeAfterLoad!

And the test case.

TestCase subclass: #Archie2ModelAppTests
    classInstanceVariableNames: ''
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''!

!Archie2ModelAppTests class publicMethods !

resources
    ^Array with: ArchiTestResource! !

!Archie2ModelAppTests publicMethods !

resource
    ^ArchiTestResource!

setUp!

tearDown!

testDummy
    self assert: (self resource isAvailable)! !

Archie2ModelAppTests initializeAfterLoad!

On Tue, Dec 30, 2014 at 5:12 PM, Louis LaBrunda <[hidden email]> wrote:
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:
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 va-smalltalk...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/va-smalltalk" target="_blank" onmousedown="this.href='http://groups.google.com/group/va-smalltalk';return true;" onclick="this.href='http://groups.google.com/group/va-smalltalk';return true;">http://groups.google.com/group/va-smalltalk.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QlD0qqDt6sJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-smalltalk...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QlD0qqDt6sJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-sma...@....
Visit this group at <a href="http://groups.google.com/group/va-smalltalk" target="_blank" onmousedown="this.href='http://groups.google.com/group/va-smalltalk';return true;" onclick="this.href='http://groups.google.com/group/va-smalltalk';return true;">http://groups.google.com/group/va-smalltalk.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

jtuchel
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Wayne Johnston
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Dusty-2
In reply to this post by jtuchel
I simply did this:

setUp
    self archiConsole isNil ifTrue: [
        archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart
    ].
    [self archiConsole available]
        whileFalse: [
            AbtTimedWait forSeconds: 5
            ].
    self login.
    self setup.


so, archiConsole will make 'available' true when its finished starting up.
After that I can set some stuff up for my tests.

On Tue, Jan 6, 2015 at 3:59 PM, Joachim Tuchel <[hidden email]> wrote:
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

jtuchel
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:
I simply did this:

setUp
    self archiConsole isNil ifTrue: [
        archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart
    ].
    [self archiConsole available]
        whileFalse: [
            AbtTimedWait forSeconds: 5
            ].
    self login.
    self setup.


so, archiConsole will make 'available' true when its finished starting up.
After that I can set some stuff up for my tests.

On Tue, Jan 6, 2015 at 3:59 PM, Joachim Tuchel <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3O2z8BXZJm0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">jtu...@...> wrote:
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3O2z8BXZJm0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-smalltalk...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="3O2z8BXZJm0J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">va-sma...@....
Visit this group at <a href="http://groups.google.com/group/va-smalltalk" target="_blank" onmousedown="this.href='http://groups.google.com/group/va-smalltalk';return true;" onclick="this.href='http://groups.google.com/group/va-smalltalk';return true;">http://groups.google.com/group/va-smalltalk.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Richard Sargent
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:
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:
I simply did this:

setUp
    self archiConsole isNil ifTrue: [
        archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart
    ].
    [self archiConsole available]
        whileFalse: [
            AbtTimedWait forSeconds: 5
            ].
    self login.
    self setup.


so, archiConsole will make 'available' true when its finished starting up.
After that I can set some stuff up for my tests.

On Tue, Jan 6, 2015 at 3:59 PM, Joachim Tuchel <[hidden email]> wrote:
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 va-smalltalk...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at <a href="http://groups.google.com/group/va-smalltalk" target="_blank" onmousedown="this.href='http://groups.google.com/group/va-smalltalk';return true;" onclick="this.href='http://groups.google.com/group/va-smalltalk';return true;">http://groups.google.com/group/va-smalltalk.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Dusty-2
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.
Your explanation makes sense in this regard, and I find it perfectly acceptable to ensure setUp only finishes when things are, indeed, set up.

Thanks for your time and explanation.

Kind Regards
Dusty

On Wed, Jan 7, 2015 at 7:07 PM, Richard Sargent <[hidden email]> wrote:
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:
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:
I simply did this:

setUp
    self archiConsole isNil ifTrue: [
        archiConsole := ((Archie2ServerDIsplay newInShellView) openWidget) parentPart
    ].
    [self archiConsole available]
        whileFalse: [
            AbtTimedWait forSeconds: 5
            ].
    self login.
    self setup.


so, archiConsole will make 'available' true when its finished starting up.
After that I can set some stuff up for my tests.

On Tue, Jan 6, 2015 at 3:59 PM, Joachim Tuchel <[hidden email]> wrote:
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 va-smalltalk...@googlegroups.com.
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.

--
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.

--
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.
Reply | Threaded
Open this post in threaded view
|

Re: SUnit TestCase not waiting for TestResource to become available

Richard Sargent
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.