How to run scenarios in calabash android without reset - calabash-android

I want to run a feature file containing different szenarios. Without a reset after each szenario.
I tried to run this test by command line with 'RESET_BETWEEN_SCENARIOS' tag.
RESET_BETWEEN_SCENARIOS=0 calabash-android run
doesn't work.
I tried to uncomment ('#') some lines in app_life_cycle_hooks.rb file:
require 'calabash-android/management/adb'
require 'calabash-android/operations'
Before do |scenario|
#start_test_server_in_background
end
After do |scenario|
if scenario.failed?
screenshot_embed
end
#shutdown_test_server
end
doesn't work.
I tried to uncomment die following lines in app_installation_hooks.rb
uninstall_apps
install_app(ENV['TEST_APP_PATH'])
install_app(ENV['APP_PATH'])
doesn't work.

Got it.
I removed (by comment) this line in app_installation_hooks.rb
uninstall_apps
and this lines in app_life_cycle_hooks.rb
start_test_server_in_background
shutdown_test_server
I created a file start_server.rb in /step_definitions defined a custom step:
Given /^I started the server$/ do
start_test_server_in_background
end
which I used in my first scenario
Scenario: S1
Given I started the server
...
I run this by my .sh script (in shell) including the run statement
calabash-android run PATH_TO_APK

Related

Is it possible to disable the syntax check when running molecule test?

I have role, role-1, that I'm testing that is dependent on another role, role-2.
I clone the second role, role-2, into /tmp during the prepare step, and it is imported later from /tmp during the converge, however during the
INFO Running default > syntax
I get an error, that role-2 is not found, as this role is not yet cloned and does not exist on the system.
From the debug/verbose output it look like molecule test result in the following command being run
COMMAND: ansible-playbook --diff --inventory /home/vagrant/.cache/molecule/role-1/default/inventory --skip-tags molecule-notest,notest --syntax-check /opt/role-1-role/ansible/roles/role-1/molecule/default/converge.yml
Is there a way to stop this command running the --syntax-check, override the default command that molecule test runs? Or the have the syntax-check skip certain tasks or files?
Just found that you can add scenario to the molecule.yml file and overwrite/re-order the test sequence, so that solves the issue I was having, by reordering the sequence so that the syntax check happened after the prepare step.
See molecule.scenario

Testing net/http?

I am a little confused about how to structure a go web app and its tests. I have read the How to Write Go Code but still don't get it. For example, I have a go project called "beacon" with a beacon.go file at the root. Adding a trivial beacon_test.go file (copied verbatim from http://golang.org/pkg/net/http/httptest/#example_Server) causes this error:
$ go test
# github.com/jelder/beacon
./beacon_test.go:11: main redeclared in this block
previous declaration at ./beacon.go:216
FAIL github.com/jelder/beacon [build failed]
Sure enough, line 11 is func main(). If I instead change the package main line in my beacon_test.go to package hello, I get this error instead:
can't load package: package github.com/jelder/beacon: found packages main (beacon.go) and hello (beacon_test.go) in /Users/jacob/src/github.com/jelder/beacon
beacon_test.go has also a function called main() rename it to TestFirst (or any other name you like as long as it starts with Test, note the uppercase T is important). There is no need for that. Just run go test . from inside the package you are working on (the one containing the *.go files). Post the full files if you need more help.

How detect failure of Web Performance Test run from command line

I've got a visual studio 'web performance test' to run from the command line. The plan is to create a scheduled task to run this. How do i trigger an email on failure? Either I wire that logic up in the test itself or it's external and dependent on return code but i don't think there is a return value - i.e. failure is shown in output text or by checking the saved results file.
You can use the /resultsfile:[ file name ] option with mstest.exe to create a ".trx" file. Its contents is XML and it contains a section similar to:
<ResultSummary outcome="Completed">
<Counters total="1" executed="1" passed="1" error="0" failed="0"
timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0"
notRunnable="0" notExecuted="0" disconnected="0" warning="0"
completed="0" inProgress="0" pending="0" />
</ResultSummary>
(Extra white space added for clarity).
It should be a simple matter to examine the TRX file after the run and send an email if anything failed.

How can I stop sourcing a (t)csh script on a certain condition without exiting the shell?

I have to source a tcsh script to modify environment variables.
Some tests are to be done and if any fails the sourcing shall stop without exiting the shell. I do not want to run the script as a subprocess because I would need to modify env variables in the parent process which a subprocess cannot do. This is similar but different to this question where the author actually can run the script as a subprocess.
The usual workaround is to create an alias which runs a script (csh/bash/perl/python/...) which writes a tempfile with all the env var settings and at the end sources & deletes that tempfile. Here's more info for those interested (demoing a solution for bash). For my very simple and short stuff I'm doing that additional alias is not wanted.
So my workaround is to provoke a syntax error which stops any source execution. Here's an example:
test $ADMIN_USER = `filetest -U: $SOME_FILE` || "Error: Admin user must own admin file"
The shortcircuit || causes the error text to be ignored in case of goodness. On a test failure the error text is interpreted as a command, not found, the source stops and produces a reasonable error message:
Error: Admin user must own admin file: Command not found.
Is there any nicer way in doing this? Some csh/tcsh built-in that I've overlooked?
Thanks to a discussion with the user shellter I just verified my assumption that
test $ADMIN_USER = `filetest -U: $SOME_FILE` || \
echo "Error: Admin user must own admin file" && \
exit
would actually quit the enclosing interactive shell. But it does not.
So the answer to my above question actually is:
Just use a normal exit and the source will stop sourcing the script while keeping the calling interactive shell running.

How to run a vim script interactively from vim command line?

Is there a way to run these scripts from the : commandline with a few keystrokes?
Over the last couple of months, I've built a series of files full of vim-commands to auto-generate boilerplate code for my projects. It's allowed me to work faster.
However, the only way I know how to run these scripts is by assigning them to key-combinations in ~/.vimrc. There's only so many keys I can remap.
Is there a way to run these scripts from the : commandline with a few keystrokes?
For example, I have a unit_test_cpp.vim script, which builds a boilerplate unit test cpp file. I'd like to be able to type
:utc
or some other simple combination of letters with a simple mnemonic to run this script on my currently open file.
Open Vim and enter the following:
:source /path/to/vim/file/name.vim
If you are currently editing that file, you can also type:
:w <ENTER>
:source % <ENTER>
The percent sign (%) means the path to the currently opened file.
You could use the command feature of vim. In your unit_test_cpp.vim file you would add something like this:
command Utc call CreateUnitTests()
Now when you type :Utc it will call your function. The only limitation is that your command must start with an uppercase letter.
Script or function? If it is a function, try
:call FunctionName()
:run file.vim
:run is like :source, but :run doesn't need the path. It searches the runtimepath.
A Linux runtimepath:
$HOME/.vim,
$VIM/vimfiles,
$VIMRUNTIME,
$VIM/vimfiles/after,
$HOME/.vim/after