I have a feature file with 5 scenarios :
#Scenario_1
#labelA
Given....
#Scenario_2
#labelB
Given....
#Scenario_3
#labelA
Given....
#Scenario_4
#labelA
Given...
#Scenario_5
#labelB
Given...
On my system, it executes in the same order in which it is present on the FF - 1,2,3,4,5. However, on a VM, it executes in any random order, like 4,1,5,3,2.
I need 1 to be compulsorily executed before 2, and 2 to be compulsorily executed before 3 and so on. Is there a way to force Cucumber to run the scenarios in the order in which they are present in the feature file ?
to do this one way is : to order the features at the lauching of the cucumber executable :
i.e.
./cucumber.sh myfeatures\second\1.feature features\first\2.feature features
where will be executed in order:
myfeatures\second\1.feature, then
features\first\2.feature, then
features.
Related
Example feature scenario is
#JIRA_BOND_007
#manual
#manual-result:passed
#manual-last-tested:sprint-1
#manual-test-evidence:https://some.external/link.png
Scenario: Dont want Manual steps to cause step definition failure
Given John Ferguson Smart releases a new version of serenity bdd
When tester marks a test as manual
Then runner should not fail because of error "io.cucumber.junit.UndefinedStepException:"
error example:
#When("tester marks a test as manual")
public tester_marks_a_test_as_manual(){
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
**io.cucumber.junit.UndefinedStepException:**
I want these scenarios tagged #manual to show in serenity report but not cause the runner to throw error because its looking for step definitions that dont exist.
it seems that we have now way around this as per comments from John Ferguson Smart:
"However, Cucumber does not allow steps to not have a step definition (they will result in a build failure). There isn't an easy work-around to this: "
I am running 10 cases, every time some test fails due to environment instability, I have used iretry analyzer and resolved this issue by running my #test methods 3 times. Now the problem is in the testing reports am getting the failed as well passed results for the same test case, I want to remove the failed case which passed on rerun in the report
Detailed explanation:
Running test 1-5
TC1 - pass
TC2 - pass
TC3 - fail
TC3 - pass (on retry using retry analyzer)
TC4 - Pass
TC5 - pass
The report is capturing test case TC3 2 times and at the end the report shows that this suite is a failure. How to overcome it?
I'm using scala_specs2_junit_test test rule and I want to pass the test a system property (what you can usually do with -DmyProp=myValue.
I found this thread which sounds related but it talks about java (native rule which has access to command line arguments) and run (vs test).
Is this possible?
You can use --test_arg, but the test rule itself must interpret such flags.
The scala_specs2_junit_test macro wraps a scala_junit_test rule. As a test rule, the latter must write ctx.outputs.executable (see rule()#test) which is what Bazel executes upon bazel test //my:test and passes the --test_arg flags to.
I didn't find any logic in the Scala rules that would parse --jvm_flags flags, so it seems they need to be updated to handle that.
Demo
<workspace>/my_test.bzl:
def _my_test_impl(ctx):
ctx.file_action(
ctx.outputs.executable,
"\n".join([
"#!/bin/bash",
"echo \"DEBUG: Hello from $(basename $0)\"",
"echo \"DEBUG: Argv=($#)\"",
# Flag parsing (e.g. --jvm_flags) would have to happen here
]),
True)
my_test = rule(
implementation = _my_test_impl,
test = True,
)
<workspace>/BUILD:
load("//:my_test.bzl", "my_test")
my_test(
name = "my_test",
)
Output:
$ bazel test //:my_test --test_output=streamed -t- --test_arg=--foo=bar --test_arg=--jvm_flags=blah
(...)
INFO: (14:45:05.379) Found 1 test target...
DEBUG: Hello from my_test
DEBUG: Argv=(--foo=bar --jvm_flags=blah)
Target //:my_test up-to-date:
bazel-bin/my_test
INFO: (14:45:05.501) Elapsed time: 0.393s, Critical Path: 0.11s
INFO: (14:45:05.501) Build completed successfully, 3 total actions
//:my_test PASSED in 0.1s
EDIT: added comment to my_test.bzl to highlight where the flag parsing would happen
You can always set a system property in Java programatically using System.setProperty(name, value).
The drawback to doing this in a unit test is that the property will stay set after the test. Make sure you set the value to null after the test.
With reference to my previous question,
Executing a lisp function from Java
I was able to call lisp code from Java using ABCL.
But the problem is, the already existing lisp code uses CL-PPCRE package.
I can not compile the code as it says 'CL-PPCRE not found'.
I have tried different approaches to add that package,
including
1) how does one compile a clisp program which uses cl-ppcre?
2)https://groups.google.com/forum/#!topic/cl-ppcre/juSfOhEDa1k
Doesnot work!
Other thing is, that executing (compile-file aima.asd) works perfectly fine although it does also require cl-pprce
(defpackage #:aima-asd
(:use :cl :asdf))
(in-package :aima-asd)
(defsystem aima
:name "aima"
:version "0.1"
:components ((:file "defpackage")
(:file "main" :depends-on ("defpackage")))
:depends-on (:cl-ppcre))
The final java code is
interpreter.eval("(load \"aima/asdf.lisp\")");
interpreter.eval("(compile-file \"aima/aima.asd\")");
interpreter.eval("(compile-file \"aima/defpackage.lisp\")");
interpreter.eval("(in-package :aima)");
interpreter.eval("(load \"aima/aima.lisp\")");
interpreter.eval("(aima-load 'all)");
The error message is
Error loading C:/Users/Administrator.NUIG-1Z7HN12/workspace/aima/probability/domains/edit-nets.lisp at line 376 (offset 16389)
#<THREAD "main" {3A188AF2}>: Debugger invoked on condition of type READER-ERROR
The package "CL-PPCRE" can't be found.
[1] AIMA(1):
Can anyone help me?
You need to load cl-ppcre before you can use it. You can do that by using (asdf:load-system :aima), provided that you put both aima and cl-ppcre into locations that your ASDF searches.
I used QuickLisp to add cl-ppcre (because nothing else worked for me).
Here is what I did
(load \"~/QuickLisp.lisp\")")
(quicklisp-quickstart:install)
(load "~/quicklisp/setup.lisp")
(ql:quickload :cl-ppcre)
First 2 lines are only a one time things. Once quickLisp is installed you can start from line 3.
I have a very simple generic for loop that is causing problems when I attempt to build the project using gradle:
for(TaskAttribute taskAttribute:task.getAttributes())
{
...
}
Task.java
protected final Set<TaskAttribute> attributes = new HashSet<TaskAttribute>();
public Set<TaskAttribute> getAttributes(){return(attributes);}
The error I am getting is that the for loop is getting Object, but requries TaskAttribute. I have my sourceCompatibility set to 1.6. Am I missing something else?
In groovy you can do for loops one of two ways.
task forLoopTest {
// print numbers 8 to 19 inclusive
for (x in 8..19) {
println 'this is run '+x
}
// print numbers 0 to 4
println 'now some groovy'
for(int i = 0;i<5;i++) {
println i
}
}
Run on CLI:
$ gradle forLoopTest
This should out put.
this is run 8
this is run 9
this is run 10
this is run 11
this is run 12
this is run 13
this is run 14
this is run 15
this is run 16
this is run 17
this is run 18
this is run 19
0
1
2
3
4
The basic set up for the enhanced for loop is :
for(<Object_Type> <Object_Name> : <Collection_Name>)
I am not sure what task.getAttributes() returns or what task is, but if you have a Collection( a Set) called attributes you should just change your loop to this:
for(TaskAttribute taskAttribute : attributes)
{
...
}
Note: Since this is a private Set you may be trying to use this from another class, so getAttributes() might be returning a reference to the Set object. In which case my answer may not be useful.
Your code looks fine. Make sure you clean the project and rerun.
What is likely happening is that the type of task is a raw type, of a class that is generic (i.e. it can be parameterized but you didn't parameterize it). If this is the case, I know that logically it shouldn't make a difference on the result of the getAttributes() method; but using raw types "turns off" generics and so it says getAttributes() returns just Set, without its parameter, which causes things you get out of it to be Object.