Spock - exclude test class from being in test report - groovy

I have some tests I'd like to exclude from the spock-report. Is it possible to exclude specific classes or tests from generating it?

I don't know of such a feature out of the box but you could write your own report template.
just copy the default templates and add your filter code directly to the template.
another way I could imagine is that you run your tests twice and exclude the tests to hide with an #IgnoreIf annotation (http://mrhaki.blogspot.com/2014/06/spocklight-ignore-specifications-based.html?m=1). This could make the decision based on an environment variable.
However, tests are important and it is even more important what has NOT been tested. So you should report that certain tests where excluded in order to have a valid test report.

Related

how to make sure gitlab MR contains unit testcase or not

I want to enforce that each GitLab MR should contain unit test case(s).
how to make sure GitLab MR contains unit test case or not
Thank you!
I think a better way is to check what you actually want. You want new code tested. Instead of checking whether the merge request contains a unit test, I think its better to check code coverage.
For this you can use coverage tools like Jacoco for java, Istanbul for Javascript, etc.. GitLab has a way to include this Code Coverage Information directly into the merge Request which I think is a better solution. Now you get line by line information if the new code is tested.
GitLab Merge Request Test Coverage

How to generate excel report me karate framework? [duplicate]

I want to have an option on the cucumber report to mute/hide scenarios with a given tag from the results and numbers.
We have a bamboo build that runs our karate repository of features and scenarios. At the end it produces nice cucumber html reports. On the "overview-features.html" I would like to have an option added to the top right, which includes "Features", "Tags", "Steps" and "Failures", that says "Excluded Fails" or something like that. That when clicked provides the same exact information that the overview-features.html does, except that any scenario that's tagged with a special tag, for example #bug=abc-12345, is removed from the report and excluded from the numbers.
Why I need this. We have some existing scenarios that fail. They fail due to defects in our own software, that might not get fixed for 6 months to a year. We've tagged them with a specified tag, "#bug=abc-12345". I want them muted/excluded from the cucumber report that's produced at the end of the bamboo build for karate so I can quickly look at the number of passed features/scenarios and see if it's 100% or not. If it is, great that build is good. If not, I need to look into it further as we appear to have some regression. Without these scenarios that are expected to fail, and continue to fail until they're resolved, it is very tedious and time consuming to go through all the individual feature file reports and look at the failing scenarios and then look into why. I don't want them removed completely as when they start to pass I need to know so I can go back and remove the tag from the scenario.
Any ideas on how to accomplish this?
Karate 1.0 has overhauled the reporting system with the following key changes.
after the Runner completes you can massage the results and even re-try some tests
you can inject a custom HTML report renderer
This will require you to get into the details (some of this is not documented yet) and write some Java code. If that is not an option, you have to consider that what you are asking for is not supported by Karate.
If you are willing to go down that path, here are the links you need to get started.
a) Example of how to "post process" result-data before rendering a report: RetryTest.java and also see https://stackoverflow.com/a/67971681/143475
b) The code responsible for "pluggable" reports, where you can implement a new SuiteReports in theory. And in the Runner, there is a suiteReports() method you can call to provide your implementation.
Also note that there is an experimental "doc" keyword, by which you can inject custom HTML into a test-report: https://twitter.com/getkarate/status/1338892932691070976
Also see: https://twitter.com/KarateDSL/status/1427638609578967047

How to add an option to Cucumber report to remove scenarios that have a certain tag

I want to have an option on the cucumber report to mute/hide scenarios with a given tag from the results and numbers.
We have a bamboo build that runs our karate repository of features and scenarios. At the end it produces nice cucumber html reports. On the "overview-features.html" I would like to have an option added to the top right, which includes "Features", "Tags", "Steps" and "Failures", that says "Excluded Fails" or something like that. That when clicked provides the same exact information that the overview-features.html does, except that any scenario that's tagged with a special tag, for example #bug=abc-12345, is removed from the report and excluded from the numbers.
Why I need this. We have some existing scenarios that fail. They fail due to defects in our own software, that might not get fixed for 6 months to a year. We've tagged them with a specified tag, "#bug=abc-12345". I want them muted/excluded from the cucumber report that's produced at the end of the bamboo build for karate so I can quickly look at the number of passed features/scenarios and see if it's 100% or not. If it is, great that build is good. If not, I need to look into it further as we appear to have some regression. Without these scenarios that are expected to fail, and continue to fail until they're resolved, it is very tedious and time consuming to go through all the individual feature file reports and look at the failing scenarios and then look into why. I don't want them removed completely as when they start to pass I need to know so I can go back and remove the tag from the scenario.
Any ideas on how to accomplish this?
Karate 1.0 has overhauled the reporting system with the following key changes.
after the Runner completes you can massage the results and even re-try some tests
you can inject a custom HTML report renderer
This will require you to get into the details (some of this is not documented yet) and write some Java code. If that is not an option, you have to consider that what you are asking for is not supported by Karate.
If you are willing to go down that path, here are the links you need to get started.
a) Example of how to "post process" result-data before rendering a report: RetryTest.java and also see https://stackoverflow.com/a/67971681/143475
b) The code responsible for "pluggable" reports, where you can implement a new SuiteReports in theory. And in the Runner, there is a suiteReports() method you can call to provide your implementation.
Also note that there is an experimental "doc" keyword, by which you can inject custom HTML into a test-report: https://twitter.com/getkarate/status/1338892932691070976
Also see: https://twitter.com/KarateDSL/status/1427638609578967047

cucumber scenario with more than one tags

Is it possible to add more than one tag to a cucumber scenario?
For example, I have a test which I need to include in smoke test as well as regression tests. When I add 2 tags to the scenario, it is getting skipped
Yes, you can add multiple tags. For more information, see the Cucumber documentation

Clean up coded ui test

I created data-driven coded ui test with more iterations. When I run the test and when first iteration is done, I want do put some clean up code before every other iteration to clean all changes that are made in the previous iteration.
Any idea how to do that?
Coded UI tests allow method with the [TestCleanup] attribute. Such methods are run after each test. If you are creating Coded UI test file you should find an example of a [TestCleanup] in comments in the CodedUItestN.cs file.
Methods with [ClassCleanup] and [AssemblyCleanup] attributes are also supported.
This SO question has more information Test Method that runs once at the Start of the Test?

Resources