-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Xray integration #1902 #2089
Xray integration #1902 #2089
Conversation
private static Element addCustomTags(Element testCase, Document doc, ScenarioResult sr){ | ||
//Adding requirement and test tags | ||
Element properties = null; | ||
String custom_tags = System.getProperty("custom_tags"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks ! first please edit the PR to target the develop
branch.
what are these system properties ? is this some X-Ray thing custom_tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited to target the develop
branch.
I wanted this change to be as generic as possible to serve Xray purpose but also to be able to be reused for other tools. As such it is possible to define the tags that will be used in the Scenarios and the correspondent tags that will appear in the Junit XML report. For that in the @BeforeAll or @BeforeClass we can define what we want:
@BeforeClass
public static void beforeClass() {
System.setProperty("custom_tags", "test, requirement");
System.setProperty("custom_xml_tags", "test_key, requirement");
}
We must use custom_tags
and custom_xml_tags
that is what this code change is searching for.
If this definition is set and match the tags added in the Scenario it will add the properties
element to the Junit XML report, if not nothing will be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CMCunha to be very honest I don't like this. karate snapshots the system.env when a suite starts (and I'm not sure what the life cycle is if junit 5 etc) and it is immutable. any config in my opinion should be driven via the cli Main
or the Runner.Builder
. so I vote for removing this. if this is some accepted industry standard, we can add a method similar to outputCucumberJson()
but right now I'm not convinced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you for your feedback @ptrthomas .
The other options you suggested were adding n option in the cli Main
(like you suggested) in a specific new option or by the -D
entry that means that every time I want to execute tests I need to add those options to the execution command, that doesn't seem an easy option for the user.
Or adding an option in the Runner.Builder
that will enable and configure this feature, like adding a method custom_tags()
, did I get the right idea?
I saw that there is a config file in Karate, I tried to add configuration values there but were unable to get those in the ReportUtils.java
class, do you think it is possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CMCunha how about we just release this without this system property thing. I was curious if this is documented somewhere as a standard e.g the custom_tags
name etc.
and after users try it and really feel / explain why they need some extra configuration, we can consider. I don't want to waste time on this if no-one needs it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok @ptrthomas, I removed the system property as suggested.
Now all tags that follow format @key=value
will be added to a properties element in XML report.
|
||
/** | ||
* | ||
* @author pthomas3 | ||
*/ | ||
public class KarateJunitTest { | ||
|
||
@BeforeClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks ! just remove these and I will merge immediately
Xray integration #1902
Description
Code to enable the addition of custom Junit tags in the scenarios that will generate a element in the XML report.
Set custom tags in env variables:
Use them in the Scenarios:
And it will generate a new XML Element in the report:
<properties><property name="requirement" value="CALC-2"/><property name="test_key" value="CALC-2"/></properties>