Intellij configuration for controller tests
This section is very similar to the previous section the only difference is that now we want to run tests and not the application. Creating configurations for tests are quite similar except for some parts. There are 2 different type of configurations we can create for tests. One is a configuration that just runs one particular test and the other runs all the tests.
Please follow similar steps and ideas from the previous section while trying to complete this part.
Configuration to run all the tests
-
Open IntelliJ IDEA:
-
Launch IntelliJ IDEA and open your backend project.
-
-
Creating a Run Configuration:
-
Navigate to "Run" button on the top menu, then next to it there is a dropdown. Click on it then select "Edit Configurations…"
-
Click the "+" icon and choose the appropriate configuration type, since we are trying to run test(s) select the "TestNG" configuration type.
-
-
Setting Configuration Details:
-
Name the configuration appropriately. Define the "test kind" option as "All in package" as we want to run with all the tests in the packcage it is under. Fill up the environment variables such that it runs on the local host as we are running tests. Select the "blg-akaun-platform-java.akaun-api.test" package under "Use classpath of module" section. Choose the correct JRE which is 16 in our case. Finally in the "Shorten command line" option choose "JAR manifest".
-
-
Saving the Configuration:
-
Save the configuration for future use by clicking "Appy" and "Ok".
-

Example Run Configuration For All Tests
Consider a scenario where we want to run all the tests for the application for our local database. We want to run the tests only on our local database.
These are the example configuration specifics:
-
Test kind: All in package (Across module dependencies - radio button)
-
Environment Variables:
-
DB_HOST = localhost (or) 127.0.0.1 (it is the IP address of localhost)
-
DB_NAME = postgres
-
DB_PASS = akaun
-
DB_PORT = 5432
-
DB_USER = akaun
-
-
Class Path (-cp): blg-akaun-platform-java.akaun-api.test
-
JRE: 16
-
Shorten commnand line: JAR manifest
Configuration to run a single test
-
Open IntelliJ IDEA:
-
Launch IntelliJ IDEA and open your backend project.
-
-
Creating a Run Configuration:
-
Navigate to "Run" button on the top menu, then next to it there is a dropdown. Click on it then select "Edit Configurations…"
-
Click the "+" icon and choose the appropriate configuration type, since we are trying to run test(s) select the "TestNG" configuration type.
-
-
Setting Configuration Details:
-
Name the configuration appropriately. Define the "test kind" option as "Class" as we want to run only one particular test class. Then select the test class (ControllerTest class) you want to run. Fill up the environment variables such that it runs on the local host as we are running tests. Select the "blg-akaun-platform-java.akaun-api.test" package under "Use classpath of module" section. Choose the correct JRE which is 16 in our case. Finally in the "Shorten command line" option choose "JAR manifest".
-
-
Saving the Configuration:
-
Save the configuration for future use by clicking "Appy" and "Ok".
-

Example Run Configuration For Single Tests
Consider a scenario where we want to run all the tests for the application for our local database. We want to run the tests only on our local database.
These are the example configuration specifics:
-
Test kind: Class
-
Environment Variables:
-
DB_HOST = localhost (or) 127.0.0.1 (it is the IP address of localhost)
-
DB_NAME = postgres
-
DB_PASS = akaun
-
DB_PORT = 5432
-
DB_USER = akaun
-
-
Class Path (-cp): blg-akaun-platform-java.akaun-api.test
-
JRE: 16
-
Shorten commnand line: JAR manifest