• Home
Name Date Size #Lines LOC

..--

native/03-May-2024-13,6459,507

unit/03-May-2024-4,0643,118

README.mdD03-May-20242.6 KiB9680

README.md

1# ImsMedia UnitTests Suite
2
3## 1. Introduction
4- The `tests/` directory in _ImsMedia_ contains all the _ImsMedia_'s Unit Tests.
5- As _ImsMedia_ consists of both java and native code, Unit Tests are divided into two major testmodules.
6    * `ImsMediaJavaTests`   - _consists all junit tests._
7    * `ImsMediaNativeTests` - _consists all gtest tests._
8- A testgroup is a collection of multiple testmodules.
9    * `ImsMedia-alltests`  - _consists two testmodules explained above._
10
11
12## 2. Procedure to run tests with atest
13
14Create and connect Cuttlefish before executing atest commands.
15
16```
17gcert
18acloud create --local-image
19acloud reconnect
20```
21#### 2.1 To run all tests in ImsMedia
22```
23atest -c --rebuild-module-info
24```
25
26#### 2.2 To run all tests in a testgroup
27A testgroup is a collection of multiple testmodules.
28
29```
30atest --test-mapping :<TESTGROUP>
31```
32Example: To run all testmodules in `ImsMedia-alltests` testgroup.
33```
34atest --test-mapping :ImsMedia-alltests
35```
36
37#### 2.3 To run all tests in a testmodule
38```
39atest <TESTMODULE>
40```
41Example: To run all tests in `ImsMediaNativeTests` testmodule
42```
43atest ImsMediaNativeTests
44```
45
46#### 2.4 To run all tests in a test class
47```
48atest <TESTMODULE>:<TESTCLASS>
49```
50Example: To run all tests in _RtpBufferTest_ test class in `ImsMediaNativeTests` testmodule
51```
52atest ImsMediaNativeTests:RtpBufferTest
53```
54
55## 2.5 To build and run tests if new test is added
56
57- Add `--rebuild-module-info` as last argument for any atest command to build and run.
58- Add `-c` as first argument for any atest command to clean old cache.
59
60Example: To build and run a test module along with clear cache:
61```
62atest -c <TESTMODULE> --rebuild-module-info
63```
64Example: To build and run `ImsMediaNativeTests` testmodule if new test is added
65```
66atest -c ImsMediaNativeTests --rebuild-module-info
67```
68
69
70## 3. Procedure to run tests without atest
71
72After building _ImsMedia_ with `mm` command, connect Cuttlefish.
73
74#### 3.1 Sync tests to Cuttlefish/device
75```
76$ adb root
77$ adb remount
78$ adb sync
79```
80#### 3.2.1 Run native tests on Cuttlefish/device
81```
82adb shell ./data/nativetest64/<TESTMODULE>/<TESTMODULE>
83```
84Example: To run `ImsMediaNativeTests` testmodule on CVD/device
85```
86adb shell ./data/nativetest64/ImsMediaNativeTests/ImsMediaNativeTests
87```
88#### 3.2.2 Run Java tests on Cuttlefish/device
89Testapk should be installed on device
90```
91adb shell am instrument -w <test_package_name>/<runner_class>
92```
93Example: To run `ImsStackJavaTests` testmodule on CVD/device
94```
95adb shell am instrument -w com.android.telephony.imsmedia.tests.java.imsapp/androidx.test.runner.AndroidJUnitRunner
96```