Jump to content

Behat/Mink - echo a message to console within a step


Jessica

Recommended Posts

Using behat to run some tests - if I add an echo within a step, or echo in my afterStep() function, I don't get the message until all the steps are done running (so if afterStep() has echo 'test'; at the end I get testtesttestest etc.)

 

I can't find anything on google about this, I see examples where people are doing an echo within their steps, but I can't get it to work.

 

Any ideas?

Link to comment
Share on other sites

Just curious, why are you wanting to echo from an automated test? By nature they shouldn't fail, except during the initial development or after changes, but in those cases at the end is surely fine?

Link to comment
Share on other sites

For a few reasons - one is that one of our steps involves checking an email account to see if the email was recieved. The step automatically waits 30 seconds. However it doesn't output to the screen that it's checking email until after it's passed or failed, so when we are manually running the tests and watching, it sits for 30 seconds with no output. We wanted to add a simple message that says "Waiting for 30 seconds before Checking Email".

Link to comment
Share on other sites

Why do you need to physically send the email? Just mock the mailer and ensure it receives what it should. Otherwise your tests are dependant on some outside system that could fail for reasons completely unrelated to your code, which will screw up the CI environment for no reason. There should be other checks in place to spot issues with the network. Plus, as your test suite grows, you don't want 30 seconds waits dotted around, it will take forever to run them all.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.