Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

java - Allure - generate allure-results with jar

I have a big java .jar with dependencies and classes, when excute the .jar, I need to generate the folder "allure-results", Is it possible to do that?

1) execute the -jar
2) run the tests
3) generate the folder allure-results

the idea is to run without maven.

----- Solved

i create a main.

public static void main(String[] args) {

       JUnitCore engine = new JUnitCore();
       engine.addListener(new AllureJunit4());
       engine.run(testsSuitName.class);

 }

when you exec the fat jar and the test its ok, the jar create the folder "allure-results"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to add AllureJunit4 listener to JUnitCore:

JUnitCore engine = new JUnitCore();
engine.addListener(new AllureJunit4());
engine.run(testsSuitName.class);

Then you need to specify AspectJ Weaver javaagent when run your fat jar:

$ java -jar --javaagent:"/path/to/aspectjweaver.jar" tests.jar

In order to configure results folder you can use allure.results.directory system property


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...