How to run unit test within a running instance

I understand how to create Spock tests and run individual ones with gradle, but what if I want faster turnaround and do not want to wait for moqui to spin up for each try? I think what I am asking is how can I run a test programmably? Are there incompatibilities with running a test not from the command line?

1 Like

Do you mean how to run a JUnit test without using the Gradle JUnit infrastructure? There are ways… it’s all just APIs and tools that you can piece together how you will. Doing it with the JUnit infrastructure but without all the Gradle tooling and such is possible, but would be cumbersome and if you want to run a test in a different way it’s probably easier to write it without the JUnit infrastructure.

If you want to write logic to test other logic, ie keeping to the service layer, one approach is to write your test in a service and run it using the service screens in the Tools app. If it’s written using a script (XML Actions, Groovy script, etc) and not compiled you can also update your script and with the dev settings that expire caches fairly quickly it will reload automatically (after 5 seconds), so you don’t have to restart the server for that either.

2 Likes