Skip to content
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

pause scenario execution #178

Closed
patmuk opened this issue Aug 30, 2018 · 10 comments
Closed

pause scenario execution #178

patmuk opened this issue Aug 30, 2018 · 10 comments

Comments

@patmuk
Copy link

patmuk commented Aug 30, 2018

Expected behavior

I would like to pause a scenario execution and wait for the user to press the RETURN key.
This would help using gauge to script demos. I would need this to convince my colleagues to move from cucumber (as it works there).
However, I can not get StdIn :(

My could would look like this:

@Step("Wait for RETURN key pressed")
public void waitForRETURNkey(){
   System.out.println("Paused - please press RETURN to continue."): //this works
   System.in.read(); //This does not work. Is the StdIn set to dev/null?
}

Actual behavior

My Step prints Paused - please press RETURN to continue. and continues instantly.

Steps to reproduce

  1. gauge init java
  2. implement my step code above
  3. call the step from a spec file
  4. gauge run

Gauge version

Gauge version: 1.0.0

Plugins
-------
html-report (4.0.5)
java (0.6.8)
screenshot (0.0.1)

Is there a JVM option I could set?
Thanks for your help in advance, highly appreciated.

@sriv
Copy link
Member

sriv commented Sep 3, 2018

Thanks for reporting this @patmuk. You are right, the stdin was not getting redirected properly. I've pushed a commit to address this.

@gaugebot
Copy link

gaugebot bot commented Sep 3, 2018

The fix should be available in nightly >= 3-8-2018

@ajoecker
Copy link
Contributor

ajoecker commented Sep 3, 2018

Would it make sense to have an API method for this ? Just thinking

In general, I think it would be nicer to have to declare Gauge.pause() instead of the System.in.read() or similar

@patmuk
Copy link
Author

patmuk commented Sep 3, 2018

@sriv great, thanks for the fast fix!!
@ajoecker Gauge.pause() sounds good. I think writing test scenarios and using some in interactive demos is a good way, I can elaborate on that more if desired.
However, adding Gauge.pause() is as well an commitment to support pausing, and might have undesired side effects in CI environments when configured poorly (i.e. stdIn not deactivated). Though an env setting could activate/deactivate it.

Having said that, I am for Gauge.pause() :)

@sriv
Copy link
Member

sriv commented Sep 3, 2018

Some context: Someone had asked for stdin redirect earlier, with gauge-ruby. The user wanted to use pry, a library that breaks and gives a REPL for instant debugging.

Gauge.pause() was simple, too simple to honour the need of pry session. Hence we just redirected the stdin and let the user use the debugger.

If you feel having a pause API is good, then please open a feature request. It is not complicated to build :)

@patmuk
Copy link
Author

patmuk commented Sep 3, 2018

Hi @sriv,
I just tried it out with

Gauge version: 1.0.0

Plugins
-------
html-report (4.0.5)
java (0.6.9.nightly-2018-09-03)
screenshot (0.0.1)

which does not work. System.in.read() immediately returns with -1, meaning that the stream is closed.
Did you tried it? With another Java method? (Such as Scanner?)

@sriv
Copy link
Member

sriv commented Sep 3, 2018

Hi @patmuk - please try again (uninstall and reinstall gauge-java version (0.6.9.nightly-2018-09-03). The nightly build was triggered prematurely.

@ajoecker
Copy link
Contributor

ajoecker commented Sep 3, 2018

However, adding Gauge.pause() is as well an commitment to support pausing, and might have undesired side effects in CI environments when configured poorly (i.e. stdIn not deactivated). Though an env setting could activate/deactivate it.

People can do this now already, without the pause method - but I am not sure, whether it is possible to prevent the redirect under a certain environment...
and even if not, this would be discovered immediately and would not have any critical impact besides stalling the CI

@ajoecker
Copy link
Contributor

ajoecker commented Sep 3, 2018

I opened a FR getgauge/gauge#1165 - please add your thoughts and comments there

@patmuk
Copy link
Author

patmuk commented Sep 3, 2018

@sriv thanks! Works like charm now! I will close this ticket.
@ajoecker I meant that we should have a setting to en-/disable the pausing. This way one could have a different env for CI, which ignores it, while using the cli one can enable the pause.
I will write that in the ticket you created, thanks!

@patmuk patmuk closed this as completed Sep 3, 2018
@sriv sriv removed the ready for QA label Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants