How to pass dynamic folder name for HTML reports in #CucumberOptions - cucumber-jvm

Currenlty, Im passing path of HTML report generation via CucumberOptions in Runner class. however with each run the old report gets overwritten. is there a way to pass new folder name with each run or inbuilt cucumber option to generate new folder name for each run?
here is my code:
#CucumberOptions( features = "src/test/resources/features",
glue="com.bnymellon.sse.ui.step_definitions", tags = {"#demo"},
monochrome = true, plugin = {"html:output/HTML_Reports/"} )

There are three ways to override Cucumber Options.
cucumber.options="..." passed to the JVM with -Dcucumber.options="...".
The environment variable CUCUMBER_OPTIONS="...".
A cucumber-jvm.properties on the CLASSPATH with a cucumber.options="..." property.
There is a caveat; you cannot override, but only add a plugin. So you would need to remove the html plugin from your #CucumberOptions and specify the html plugin using one of the 3 methods listed above.
If you just want to avoid having to edit your runner class for each run then I would move the html plugin to:
-Dcucumber.options="--plugin html:output/HTML_Reports"
on your runner's VM arguments box. You can then edit VM arguments before each run which avoids triggering git. I often override the tags argument this way.

Related

Cucumber options: Is there any way we provide the options value using property file or excel

I am currently doing a Selenium Cucumber Project.
For that I want to pass the features, plugin, tags from my code using a property file.
Is there any way we can do that?
Please let me know if you need more info

Intelllij IDEA Ultimate 2018.1 groovy code completion does not work

I can create a Groovy project and even run it. But when I type main or print there are no auto-complete / code completion suggestions at all. I have groovy-2.4.1 in the external library folder along with Java 1.8. I find Intellij frustrating and non-intuitive to use.
In a groovy script main does show correct code completion but when I click enter it puts "main()" without the String[] args that I can see in the suggestion.
You have created a Groovy class where code has to be embedded into a class to be executable and where only class member declarations are expected (e.g. functions, fields). Select to create a Groovy script (or just delete class declaration) to be able to write executable code in top level file. See also Scripts versus classes.
I was having the same problem when I was in a rush and forgot to add a method in which to write the code. Just type 'psvm + Enter' inside the class. This will create a main method in which code completion will work. Also, you can remove the public keyword as classes and methods in Groovy are by default public.

IntelliJ type error when using Geb static content DSL with parameters

Whenever I use a static-content defined closure that takes parameters, IntelliJ will complain that the types do not match (even if I specify the type inside the closure).
For example, if I use this static content block:
static content = {
myModule { $('myModule').module(CustomModule) }
namedModule { String name -> $(".$name").module(CustomModule) }
}
Both of the above items can be used successfully in my tests, but if I was to use 'namedModule' in one of my tests as follows:
page.namedModule("moduleName").moduleMethod("blah blah blah")
IntelliJ will highlight the parameter "moduleName" in yellow with the error:
'namedModule' cannot be applied to '(java.lang.String)'
We are trying to refactor our tests in a way that means you can navigate through the code easier (e.g. avoiding any Geb/Groovy 'magic' that IntelliJ can't resolve), and this is one of the last remaining issues preventing this from being possible.
This is a known limitation to Geb support in IntelliJ. IntelliJ always treats content definitions as properties of pages and modules even though they can be parametrised. Given that Geb support in IntelliJ is open sourced we could probably add support for this.
In the mean time, as a workaround you can use methods for parametrised content instead of content definitions and IntelliJ will be able to understand these and be able to refactor them:
void namedModule(String name) {
$(".$name").module(CustomModule)
}
There are some caveats, though:
you will loose ability to use content definition options; if you need to use these for a content definition then I suggest creating a parameterised "private" content definition (for example with a _ at the beginning of the name) that you will only ever access from within the page or module
RequiredPageContentNotPresent will not be thrown even if the returned content is empty; to work around it you will either need to add manual verification to each such method or use a strategy outlined in the first bullet point with using "private" content definitions

Opening an editor for a Java class that is within a jar (with source included)

I am working on an eclipse plugin, and I'm trying to implement F3 (Open Declaration) functionality. After finding the project that contains a class, I use findType to get the IType of the class. If it a .java file in my workspace, I can use getResource to get the IFile, and then open its editor (as is described here).
However, if it's a BinaryType, then getResource returns null. I can get the class file using getClassFile, but when I use its getResource I also get null. If I try using its getPath method, I get an IPath to the jar file which contains it.
There must be some way to reach the source file, and open it in an editor, but I can't seem to find it.
Use
JavaUI.openInEditor(IJavaElement element);
to open all Java elements (such as your IType).

Adding custom code generator

When I work with certain types of files, such as: Java file, HTML file or Jasmine Test file I can generate some useful code snippets using Code > Generate option, for example:
if I am working with Java file Code > Generate allows me to insert getter, setter, constructor etc
if I am working with HTML file Code > Generate allows me to insert an XML tag
if I am working with Jasmine Text file Code > Generate allows me to insert a scaffolding of a test suit or a singe test case
I was wondering if (and how) I can add my own 'generator'. I know I can use Live Templates, but I like the fact that Code > Generate gives me a quick list of all available generators.
Yes, you can do it by writing an IntelliJ plugin and extending this class:
com.intellij.openapi.actionSystem.Action
If you create an intelliJ plugin project (just google intellij plugin developmentfor information on how to get started), hit alt-enter somewhere in your project source tree and select Action, you will get a dialog which allows you to configure where your action should appear.
You want to place it in relation to another action which already exists, for example right below it. In your case - have a look at the menu group named GenerateGroup (Generate).
Once your action is defined in this manner in your plugin.xml, build and run your plugin in the sandbox.
Now, when your action is triggered, the AnActionEvent will be fired which contains references to all the necessary information you need (current project, file, position of cursor within file, psi tree, etc).
Try to get this working so far and come back with any specific questions.
Good luck!