|
| 1 | +# Test Case Implementation Guidelines |
| 2 | +Follow the rules below when implementing test code. |
| 3 | + |
| 4 | +## Code Inspection Functionality |
| 5 | +Implement tests for code inspection functionality using the following steps: |
| 6 | + |
| 7 | +### **Implementation of Test Case Classes** |
| 8 | +- Implement test case classes in `@src/test/kotlin/org/domaframework/doma/intellij/inspection`. |
| 9 | +- Implement test cases for each subclass of **AbstractBaseJavaLocalInspectionTool**. |
| 10 | +- Name the test case class as `<InspectionToolName>InspectionTest`. |
| 11 | +- The test case class should extend `DomaSqlTest`. |
| 12 | +- Override **setUp()** to add mock **Entity** classes or other necessary components to the virtual project for testing. |
| 13 | +- Register the target **AbstractBaseJavaLocalInspectionTool** subclass using **myFixture.enableInspections**. |
| 14 | +- In test case functions, retrieve the target Dao class using **DomaSqlTest#findDaoClass()** and test the highlighting results using **myFixture.testHighlighting()**. |
| 15 | + |
| 16 | +### Implementation of Test Cases |
| 17 | +Create the target Dao class or SQL file for inspection. |
| 18 | +Wrap the elements to be error-highlighted with the **<error>** tag and specify the error message to be displayed using the **descr** option. |
| 19 | + |
| 20 | +#### Test Data for Dao Classes |
| 21 | +- Implement test data Dao classes in **Java**. |
| 22 | +- Annotate test data Dao classes with **@Dao**. |
| 23 | +- Place them under the appropriate subpackage in `@src/test/testData/src/main/java/doma/example/dao/inspection`. |
| 24 | +- Implement any other necessary classes as needed. |
| 25 | + |
| 26 | +#### Test Data for SQL Files |
| 27 | +- Create and place SQL files in a directory named after the corresponding Dao class under `@src/test/testData/src/main/resources/META-INF/doma/example/dao`. |
| 28 | + |
| 29 | +### Reference |
| 30 | +For actual implementation examples using Doma, refer to the [Doma GitHub repository](https://github.com/domaframework/doma/tree/master/integration-test-java/src/main/java/org/seasar/doma/it/dao). |
0 commit comments