serenity-bdd / serenity-jbehave

The Serenity integration for JBehave
39 stars 34 forks source link

Run tests from executable jar #205

Open sergiuciudin opened 6 years ago

sergiuciudin commented 6 years ago

Is there a way to run tests from main?

wakaleo commented 6 years ago

Yes, but not easily - it would involve some custom code and custom build scripting.

sergiuciudin commented 6 years ago

@wakaleo thank you for the fast reply :)

Can you share please the idea?

i have tried something like this but without success

https://github.com/jbehave/jbehave-core/tree/master/examples/executable-jar/src/main/java/org/jbehave/examples/executable_jar

franciscoguemes commented 5 years ago

Could you provide an example or some guidelines on how to run the tests with serenity from a *.jar file?

wakaleo commented 5 years ago

It really isn't trivial - I implemented something like this for a client a few years back for pure JUnit and it requires a fairly deep knowledge of JUnit and Serenity internals. I wouldn't know for JBehave.

franciscoguemes commented 5 years ago

And what about Cucumber-JVM ?

tibioneh commented 4 years ago

Hello, any details on how to do this? It's becoming more and more necessary apparently, to the point where we're forced to drop the framework solely because it cannot be done. A shame, really.

wakaleo commented 4 years ago

What problem are you trying to solve?

tibioneh commented 4 years ago

Ideally, having the ability to run individual tests from a packaged jar.

wakaleo commented 4 years ago

And what will this allow you to do? Test suites are typically run as part of a build process, so creating an executable jar from a Java project that includes both the tests and the application code, and a runner, really isn't simple. It's not Serenity, it's the whole Java development approach.

tibioneh commented 4 years ago

It would be just the packaged serenity project, not the application code as well. This way tests can be ran in parallel on AWS for example, or any number of other variations. The setup demands that the tests are ran in the deploy phase.

wakaleo commented 4 years ago

You could do this by putting all the tests in src/main/java and creating a main() method that triggers the JUnit runner classes. But wouldn't it be easier just to use Docker?

tibioneh commented 4 years ago

Could be, I'll give it a try. Thank you for your answer.

vulkman commented 3 years ago

@wakaleo Got it to work, only problem: I don't get an index.html in the results, probably because the step that's usually done by serenity:aggregate is missing. Could you tell me how to run that directly in my main()?

msamarba commented 1 year ago

Hello @vulkman can you please tell me how you got it working ? I currently use the maven-assembly-plugin and an assembly.xml to create that jar file. However running it locally and in Jenkins gives me nullpointerexceptions. It seems it can't see Serenity in the jar file.