vscode-java-test icon indicating copy to clipboard operation
vscode-java-test copied to clipboard

Question: how to run tests with properties from alternative pom file

Open tsaarni opened this issue 2 years ago • 5 comments

I'm trying to run tests for a project which uses Arquillian integration test framework. The project has an alternative pom.xml file (outside of the root dir of the project) which should be used when runninng tests via maven

mvn clean install -f testsuite/integration-arquillian/pom.xml

but when running tests from vscode, I get exceptions/errors that seem like I'm missing all the mandatory default properties that are defined in the pom files but are missing when running tests via vscode.

Would you have any pointers for me on how to setup Java test runner for vscode for a project like this? I'd appreciate any help!

The project I'm working with is keycloak and the pom with the (apparently ignored) properties is testsuite/integration-arquillian/tests/pom.xml.

tsaarni avatar Jan 24 '22 16:01 tsaarni

Will the test configuration help you?

https://github.com/microsoft/vscode-java-test/wiki/Run-with-Configuration

jdneo avatar Jan 25 '22 00:01 jdneo

Thanks for responding @jdneo!

I assume that if I'm able to reproduce 1:1 every needed property setting which the maven build does when running tests with a certain pom.xml and maven profile within it, it probably would work inside test runner as well. But I'm not familiar if this is the way it is assumed to be done? That is, manually go through the pom.xml and its sub-modules and create java.test.config in project's settings.json that reflects the settings found there?

Would this be done purely by inspecting the pom files, or would there be approaches that help with the conversion process?

tsaarni avatar Jan 25 '22 05:01 tsaarni

Currently we have to do it manually. This for sure can be an enhancement.

Not sure how will other IDEs(Eclipse, IntelliJ) deal with this. Have you tried them?

jdneo avatar Jan 25 '22 05:01 jdneo

Thank you @jdneo, now I know I'm not using test runner wrong! :)

Just for curiosity, I did downloaded IntelliJ and imported keycloak as maven based project. It did pick up the properties automatically from the pom files and passed them on command line when running unit test cases. There was 152 properties in the full command line, which was visible in the intellij run console. I guess similar list could be possibly exported somehow from mvn execution to help the creating java.test.config for vscode.

I will close this issue now. Thanks again!

tsaarni avatar Jan 25 '22 07:01 tsaarni

This can be a good feature request. Let's keep it open.

jdneo avatar Jan 25 '22 07:01 jdneo