How do we use 'grep' but not skipping test cases that we want them run all the time? - intern

For example we have test 1, test 2,..., test N, login Test, logout Test, what if we want to run login, test 1, logout at one time for debugging?

There isn't a way to specify that some tests are always included when using grep, so the only way to do this currently is to use a grep expression that matches only the tests you want to run, like grep="\\b(login|test 1|logout)\\b".

Related

Single Mocha tests output

I'm looking for a way to provide a single boolean output from my mocha tests instead of the standard test list. If all tests passed - it should return true, otherwise false. It's fine if it's written in a separate file on a server, we don't even need to suppress the logs, but I couldn't find a way to use the after() function to get a list of all tests that had been run and their results.
Any ideas?

Using cucumber to run different tagged features sequentially

I'm attempting to run tagged features in the order that they are submitted.
example:
I have tests that i'd like to run in a specific order (#test1, #test2, #test3). After looking at the cucumber documentation is looks like i'm only able to run them in an and/or option like
cucumber features/.feature --t #test1; cucumber features/.feature --t #test2; cucumber features/*.feature --t #test3;
but this prevents me from having a single report which contains all of the results.
Is there anyway which I can run these tests in their respective order and have all of the results contained in the same report?
If you put the tests that have to run in a specific order in a feature file together cucumber will run them in the order they are given. As this will be in your normal test run it should all show up in the same report.
But it might be worth looking into why your tests are dependant on each other and if there is a way to remove this dependancy as it is generally bad practice to have it.

Is it possible to incorporate an environment variable into a ruby script for Calabash?

I am testing a feature on an app that requires the user to be a certain age. The only time you see the prompt that asks for your age is once you open the app for the first time and once you log out of the app. I don't want my test to only go through my steps to log in and then log out to be able to see this prompt, but I also don't want to manually reset the data in between tests either. Isn't this why we write scripts? Anyways, before I launch the test, I use the environment variable RESET_BETWEEN_SCENARIOS=1 cucumber features/my_feature.feature. Is there a way that I can use this variable INSIDE of my step definition so that it resets the data on its own once I run the script?
I'm not familiar with Calabash, but it appears to be using cucumber. If that is the case, you could handle the action in a before or after hook which would run before or after each scenario.
Within the features/support folder, add a file hooks.rb
Before() do
if ENV['RESET_BETWEEN_SCENARIOS'] == '1'
#code to reset data
end
end
This could also be run after the scenario by using After() do. The same if/then could be used within a scenario step as well.

Bail suite on mocha (sub)suite error but continue next?

I'm using mocha in node.js with have bdd-style specs.
Is it possible to bail a sub-suite after the first error but continue it's parent/sibling suites?
Say I test different routes to access an api, then I want to abort a specific route if it's connection fails because there's no use hammering with calls if first action failed, but it can still attempt to check other things.
If a high level tests sees a server is completely down or misconfigured then I could abort instead of having to wait all the failing tests to timeout and fill the report with unnecessary mayhem.
I see the following answer but that's not what I want, it bails everything, which is too much. I want something to only bail a branch in the spec tree if an assertion fails.
Skip subsequent Mocha tests from spec if one fails
If you want mocha to continue processing other test files after failing on one, you could use find to run a separate instance of mocha on each file:
find test/ -name "*.js" -exec mocha {} \;
It sounds like mocha-steps may work for this:
Global step() function, as a drop-in replacement for it(). Any failing step will abort the parent describe immediately. This is handy for BDD-like scenarios, or smoke tests that need to run through specific steps.

Is there a way to run a single cucumber feature file on autotest?

I'd like to run just a single cucumber feature file on autotest. I'd like the test to be run, report failures, then run again as soon as I save a change to my code base. Anyone know a way to do this?
--Jack
I found a solution myself:
Watchr - https://github.com/mynyml/watchr
It watches whenever you save specified files and runs specified tests at that point. Uses pattern matching.

Resources