1

I have joined a new project who are using Microprofile/Openliberty. I have searched around quite a bit on the internet and it doesnt look like there is a straight forward way to write integration tests using this framework.

Some tutorials pointed me towards arquillian etc which can only run in a maven build so no support for running the tests directly from Intellij/IDE. Others need a full installation of Openliberty on your drive.

I am ideally looking for some thing similar to @SpringBootTest. And if such functionality isnt available then at a minimum I need a way to hit the API Endpoints of my app using a test HTTP client where I can ensure that the JSON I send to the endpoint is parsed correctly and the query/path params are correctly interpreted etc. The deeper part of the App I can just mock.

Is there a programmatic or otherwise way of doing this using the microprofile/openliberty framework?

Thanks in Advance :)

Javadee
  • 139
  • 10
  • So it doesnt look like there is an easy way to do this. Found some related links whilst searching around which I'm posting here for benefit of others who are stuck with using this framework. https://groups.google.com/g/microprofile/c/Zl0fuxmOHSA?pli=1 https://jasondl.ee/posts/2018/getting-started-with-eclipse-microprofile-part-4-openliberty.html https://www.baeldung.com/jersey-test – Javadee Apr 22 '22 at 08:44
  • There are a few parts to your question. Let me respond with a few comments. First, I don't know you'll find something analogous to the SpringBoot test "slices" for say just testing the JSON serialize/deserialize and path request mapping and exception handling, or just the DB layer. – Scott Kurz Apr 26 '22 at 15:42
  • You mention "running the tests directly from Intellij/IDE". Let me ask: are you specifically trying to be able to execute a single test at a time? Or are you content to run the full test suite? (Or maybe both use cases?) – Scott Kurz Apr 26 '22 at 15:44
  • So rather than using Arquillian you can of course write a test client, deploy your app and run the ITs against it using the Maven lifecycle. Rather than starting from the POM in your comment like though I'd suggest something like our Getting Started guide: https://openliberty.io/guides/getting-started.html – Scott Kurz Apr 26 '22 at 16:29
  • This guide use the 'run' and 'dev' goals in recent liberty-maven-plugin versions. These goals give you something like a full "lifecycle" for testing against Liberty, without even needing to configure goals in your POM, starting from just about any WAR packaging module. They handle deploy of your test app to a Liberty test environment installed and configured in your Maven target directory. (Also see demo vid https://openliberty.io/blog/2019/10/22/liberty-dev-mode.html) You can later configure your lifecycle to run tests in a CI/pipeline environment if desired. – Scott Kurz Apr 26 '22 at 16:37
  • If you are interested in pursuing Arquillian, start with our guide on the subject: https://openliberty.io/guides/arquillian-managed.html – Scott Kurz Apr 26 '22 at 16:39
  • For a container-oriented test approach you can check out our MicroShed Testing (https://microshed.org/microshed-testing/) guide: https://openliberty.io/guides/microshed-testing.html. This provides a small amount of function (e.g. integrating with REST Assured fluent test API and a JWT generation) on top of the popular Testcontainers support. It can help integrate with say a DB container as well as the app/server container though there are still some lifecycle issues to work through. – Scott Kurz Apr 26 '22 at 16:42
  • Finally let me link to the rest of our Open Liberty Guides: https://openliberty.io/guides/ and also our public Gitter chat: https://gitter.im/OpenLiberty/developer-experience where we'd be interested to hear your questions and also how things are going for you after sizing this up. – Scott Kurz Apr 26 '22 at 16:44
  • And one last thing: I apologize these comments don't especially conform to the StackOverflow Q&A format. There were a few questions wrapped up in there but this set a comments seemed are a more useful way to help the OP than to try to separate them out. – Scott Kurz Apr 26 '22 at 16:46
  • Thanks for your input @ScottKurz , I am assuming that you work for IBM/Openliberty. In which case my suggestion would be that the openliberty team should try following examples of SpringBoot or Quarkus(another Redhat/IBM product) and see how they make the integration testing painless for their customers(developers using their framework). If you want to compete then you would need to have an equally user friendly feature set in your framework if not better. Cheers – Javadee May 10 '22 at 07:54

0 Answers0