[jvm]java-webbit-websockets-selenium - Webbit server not ready to accept input and failed tests

36 views
Skip to first unread message

Teck Hooi Lim

unread,
Dec 10, 2013, 5:36:39 AM12/10/13
to cu...@googlegroups.com
Hi,

I failed to get this example to pass the test and the result was,

org.junit.ComparisonFailure:
Expected :212.0
Actual   :
 <Click to see difference>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at cucumber.examples.java.websockets.TemperatureStepdefs.i_should_see_temperature(TemperatureStepdefs.java:24)
    at ✽.Then I should see 212.0 fahrenheit(cucumber/examples/java/websockets/temperature_conversion.feature:11)


org.junit.ComparisonFailure:
Expected :37.8
Actual   :

It seemed to me that the tests were executed beforeTemperatureServer was ready to accept inputs. Hence, I added an arbitrary delay to TemperatureServer.start(),

public void start() throws IOException, ExecutionException, InterruptedException {
        webServer.start();
        Thread.sleep(1000); // arbitrary delay to let the Webbit complete its "startup sequence"
    }

and it worked. My question is how do I get cucumber-jvm to wait until Webbit is ready to accept request from the browser instead of a random delay? I am using Linux with JDK 1.7. Please advise.

Thanks

/lim/

aslak hellesoy

unread,
Dec 10, 2013, 5:57:56 AM12/10/13
to Cucumber Users
webServer.start().get(); // Wait for the returned Future.
 
Thanks

/lim/

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Teck Hooi Lim

unread,
Dec 10, 2013, 6:18:23 AM12/10/13
to cu...@googlegroups.com
Not good. It worked some of time when I ran the test for a few times. I presume get() waits for the Future to complete before it returns the control to the caller to continue.

aslak hellesoy

unread,
Dec 10, 2013, 8:00:19 AM12/10/13
to Cucumber Users
Please reply inline. See the list rules in the footer.


On Tue, Dec 10, 2013 at 11:18 AM, Teck Hooi Lim <ssh...@gmail.com> wrote:
Not good. It worked some of time when I ran the test for a few times. I presume get() waits for the Future to complete before it returns the control to the caller to continue.



Yes, get() blocks until the server is ready to receive requests.

There were several concurrency problems in the code which I think I have fixed:

Pull the latest and see if you can get that to work better.

Aslak
 
On Tuesday, December 10, 2013 6:36:39 PM UTC+8, Teck Hooi Lim wrote:
Hi,

I failed to get this example to pass the test and the result was,

org.junit.ComparisonFailure:
Expected :212.0
Actual   :
 <Click to see difference>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at cucumber.examples.java.websockets.TemperatureStepdefs.i_should_see_temperature(TemperatureStepdefs.java:24)
    at ✽.Then I should see 212.0 fahrenheit(cucumber/examples/java/websockets/temperature_conversion.feature:11)


org.junit.ComparisonFailure:
Expected :37.8
Actual   :

It seemed to me that the tests were executed beforeTemperatureServer was ready to accept inputs. Hence, I added an arbitrary delay to TemperatureServer.start(),

public void start() throws IOException, ExecutionException, InterruptedException {
        webServer.start();
        Thread.sleep(1000); // arbitrary delay to let the Webbit complete its "startup sequence"
    }

and it worked. My question is how do I get cucumber-jvm to wait until Webbit is ready to accept request from the browser instead of a random delay? I am using Linux with JDK 1.7. Please advise.

Thanks

/lim/

Reply all
Reply to author
Forward
0 new messages