App Studio currently supports unit testing (UT), including automatically generating UT code, detecting the entry for UT, running UT code, and displaying the UT result.

Automatically generate UT code

Open the target file, right-click the code editing area, and then choose Generate > Create Tests. The UT class file and UT code are automatically generated in the test directory.


Detect the entry for UT

Note
  • UT class files must be stored in the src/test/java directory. A Java UT class file that is not stored in this directory cannot be identified as the Java UT class.
  • For a method annotated with @Test annotation, Run Test appears, indicating the entry for UT.
After the Java UT class file is created, add the @Test annotation of org.junit.Test to the corresponding sample UT method.

Run UT code

Click the Run icon in the upper-right corner. The sample UT starts.