Is there a way to call Aggregator from java code instead of calling it from Pom.xml
prak0628 opened this issue · 12 comments
In my group , we are using serenity with JBehave . We are trying to create an executable jar for our functional testers so that they can double click on the jar and execute the test.For the same i am not able to call the aggregate phase since the executable jar does not have a pom.xml to do so.
May i please know is there any way for us to create JSON reports and the call the aggregate method via java code for eg: In @AfterStories annotation. Please advice on this.
@prak0628 I don't know the answer myself, but I have been wondering as I'd like to do the same thing. There's about 5 or 6 files in the maven plugin it seems, and you might be quicker than I am at figuring out which serenity code they call.
Hello @prak0628.
Take a look at gradle plugin, may be source of it will be helpful for you.
main line there is:
reporter.generateReportsForTestResultsFrom(reportDirectory)
Hi @prak0628
If you fell that you find answer for your question - please close this issue.
Thanks a lot!
Hi Yam,
Still the issue is not resolved and working on it.
@prak0628 if you have some additional question - just ask.
Thanks!
@yam Stranger
Iam unable to use the Gradle plug in since it needs a Project object from the Gradle API. But not sure how i can download the dependency for org.gardle.api.Project . Please let me know if you have any info.
@prak0628 you don't need gradle at all. Just use it as example of code, where reporter class are used - not more.
reporter.generateReportsForTestResultsFrom(reportDirectory)
It is simple class, and can be separately used from generating reports.
The same lines you will find in maven-plugin and ant-plugin.
We have two types of reports:
- when you run tests with serenity bdd, it creates some reports in xml, html formats, with unique names
- after that reporter class used to aggregate those reports from first step and create some statistics and so on.
@YamStranger
I do understand i have to use the above line of code.But in order to create an object for "HtmlAggregateStoryReporter" , i have to create it with mentioning Project(org.gradle.api.Project) while instantiating which iam unable to find.
@prak0628, I don't understand you
I see that you need only project name (it is string), and folder with reports. Nothing more (
May be we are talking about different sings, can you provide some example where you can try to use this class HtmlAggregateStoryReporter ?
It seems that this problem already solved.
@YamStranger @prak0628 , if you guys know the solution could you please help me because even I am looking for this
As mentioned in the above thread, take a look at the Maven or Gradle plugin source code (https://github.com/serenity-bdd/serenity-maven-plugin) - generating the reports programatically is straightforward and only needs a dependency on serenity-core.