• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <gtest/gtest.h>
17 
18 #define private public
19 #include "ability_command.h"
20 #include "ability_manager_client.h"
21 #undef private
22 #include "ability_manager_interface.h"
23 #include "hilog_wrapper.h"
24 #include "mock_ability_manager_stub.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS;
28 using namespace OHOS::AAFwk;
29 
30 namespace {
31 const std::string STRING_CLASS_NAME = "ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010";
32 const std::string STRING_USER_TESTRUNNER = "JSUserTestRunner";
33 const std::string STRING_PACKAGENAME = "com.example.myapplication";
34 const std::string STRING_PACKAGENAME1 = "com.example.myapplication1";
35 const std::string STRING_BUNDLENAME = "com.example.myapplication";
36 const std::string STRING_MODULENAME = "com.example.myapplication.MyApplication";
37 const std::string CLASS = "class";
38 const std::string UNITTEST = "unittest";
39 const std::string UNITTEST1 = "unittest1";
40 const std::string TIME = "20";
41 const std::string ANYKEY = "123";
42 const std::string ANYVALUE = "999999999";
43 }  // namespace
44 
45 class AbilityCommandTest : public ::testing::Test {
46 public:
47     static void SetUpTestCase();
48     static void TearDownTestCase();
49     void SetUp() override;
50     void TearDown() override;
51 
52     void MakeMockObjects() const;
53 
54     std::string cmd_ = "test";
55 };
56 
SetUpTestCase()57 void AbilityCommandTest::SetUpTestCase()
58 {}
59 
TearDownTestCase()60 void AbilityCommandTest::TearDownTestCase()
61 {}
62 
SetUp()63 void AbilityCommandTest::SetUp()
64 {
65     // reset optind to 0
66     optind = 0;
67 
68     // make mock objects
69     MakeMockObjects();
70 }
71 
TearDown()72 void AbilityCommandTest::TearDown()
73 {}
74 
MakeMockObjects() const75 void AbilityCommandTest::MakeMockObjects() const
76 {
77     // mock a stub
78     auto managerStubPtr = sptr<IAbilityManager>(new MockAbilityManagerStub());
79 
80     // set the mock stub
81     auto managerClientPtr = AbilityManagerClient::GetInstance();
82     managerClientPtr->proxy_ = managerStubPtr;
83 }
84 
85 /**
86  * @tc.number: Ability_Command_Test_0100
87  * @tc.name: ExecCommand
88  * @tc.desc: Verify the "aa test -" command.
89  */
90 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0100, Function | MediumTest | Level1)
91 {
92     HILOG_INFO("Ability_Command_Test_0100 is called");
93     char *argv[] = {
94         (char *)TOOL_NAME.c_str(),
95         (char *)cmd_.c_str(),
96         (char *)"-",
97     };
98     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
99 
100     AbilityManagerShellCommand cmd(argc, argv);
101     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
102 }
103 
104 /**
105  * @tc.number: Ability_Command_Test_0200
106  * @tc.name: ExecCommand
107  * @tc.desc: Verify the "aa test -zxmy" command.
108  */
109 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0200, Function | MediumTest | Level1)
110 {
111     HILOG_INFO("Ability_Command_Test_0200 is called");
112     char *argv[] = {
113         (char *)TOOL_NAME.c_str(),
114         (char *)cmd_.c_str(),
115         (char *)"-zxmy",
116     };
117     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
118 
119     AbilityManagerShellCommand cmd(argc, argv);
120     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
121 }
122 
123 /**
124  * @tc.number: Ability_Command_Test_0300
125  * @tc.name: ExecCommand
126  * @tc.desc: Verify the "aa test -h" command.
127  */
128 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0300, Function | MediumTest | Level1)
129 {
130     HILOG_INFO("Ability_Command_Test_0300 is called");
131     char *argv[] = {
132         (char *)TOOL_NAME.c_str(),
133         (char *)cmd_.c_str(),
134         (char *)"-h",
135     };
136     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
137 
138     AbilityManagerShellCommand cmd(argc, argv);
139     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
140 }
141 
142 /**
143  * @tc.number: Ability_Command_Test_0400
144  * @tc.name: ExecCommand
145  * @tc.desc: Verify the "aa test -help" command.
146  */
147 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0400, Function | MediumTest | Level1)
148 {
149     HILOG_INFO("Ability_Command_Test_0400 is called");
150     char *argv[] = {
151         (char *)TOOL_NAME.c_str(),
152         (char *)cmd_.c_str(),
153         (char *)"-help",
154     };
155     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
156 
157     AbilityManagerShellCommand cmd(argc, argv);
158     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
159 }
160 
161 /**
162  * @tc.number: Ability_Command_Test_0500
163  * @tc.name: ExecCommand
164  * @tc.desc: Verify the "aa test -b" command.
165  */
166 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0500, Function | MediumTest | Level1)
167 {
168     HILOG_INFO("Ability_Command_Test_0500 is called");
169     char *argv[] = {
170         (char *)TOOL_NAME.c_str(),
171         (char *)cmd_.c_str(),
172         (char *)"-b",
173     };
174     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
175 
176     AbilityManagerShellCommand cmd(argc, argv);
177     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
178 }
179 
180 /**
181  * @tc.number: Ability_Command_Test_0600
182  * @tc.name: ExecCommand
183  * @tc.desc: Verify the "aa test -s" command.
184  */
185 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0600, Function | MediumTest | Level1)
186 {
187     HILOG_INFO("Ability_Command_Test_0600 is called");
188     char *argv[] = {
189         (char *)TOOL_NAME.c_str(),
190         (char *)cmd_.c_str(),
191         (char *)"-s",
192     };
193     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
194 
195     AbilityManagerShellCommand cmd(argc, argv);
196     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
197 }
198 
199 /**
200  * @tc.number: Ability_Command_Test_0700
201  * @tc.name: ExecCommand
202  * @tc.desc: Verify the "aa test -s 123456 aaaaaaaaaaaaaa" command.
203  */
204 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0700, Function | MediumTest | Level1)
205 {
206     HILOG_INFO("Ability_Command_Test_0700 is called");
207     char *argv[] = {
208         (char *)TOOL_NAME.c_str(),
209         (char *)cmd_.c_str(),
210         (char *)"-s",
211         (char *)"123456",
212         (char *)"aaaaaaaaaaaaaa",
213     };
214     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
215 
216     AbilityManagerShellCommand cmd(argc, argv);
217     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
218 }
219 
220 /**
221  * @tc.number: Ability_Command_Test_0800
222  * @tc.name: ExecCommand
223  * @tc.desc: Verify the "aa test -b com.example.myapplication -l" command.
224  */
225 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0800, Function | MediumTest | Level1)
226 {
227     HILOG_INFO("Ability_Command_Test_0800 is called");
228     char *argv[] = {
229         (char *)TOOL_NAME.c_str(),
230         (char *)cmd_.c_str(),
231         (char *)"-b",
232         (char *)STRING_BUNDLENAME.c_str(),
233         (char *)"-l",
234     };
235     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
236 
237     AbilityManagerShellCommand cmd(argc, argv);
238     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
239 }
240 
241 /**
242  * @tc.number: Ability_Command_Test_0900
243  * @tc.name: ExecCommand
244  * @tc.desc: Verify the "aa test -b com.example.myapplication" command.
245  */
246 HWTEST_F(AbilityCommandTest, Ability_Command_Test_0900, Function | MediumTest | Level1)
247 {
248     HILOG_INFO("Ability_Command_Test_0900 is called");
249     char *argv[] = {
250         (char *)TOOL_NAME.c_str(),
251         (char *)cmd_.c_str(),
252         (char *)"-b",
253         (char *)STRING_BUNDLENAME.c_str(),
254     };
255     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
256 
257     AbilityManagerShellCommand cmd(argc, argv);
258     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
259 }
260 
261 /**
262  * @tc.number: Ability_Command_Test_1000
263  * @tc.name: ExecCommand
264  * @tc.desc: Verify the "aa test -s unittest" command.
265  */
266 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1000, Function | MediumTest | Level1)
267 {
268     HILOG_INFO("Ability_Command_Test_1000 is called");
269     char *argv[] = {
270         (char *)TOOL_NAME.c_str(),
271         (char *)cmd_.c_str(),
272         (char *)"-s",
273         (char *)UNITTEST.c_str(),
274     };
275     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
276 
277     AbilityManagerShellCommand cmd(argc, argv);
278     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
279 }
280 
281 /**
282  * @tc.number: Ability_Command_Test_1100
283  * @tc.name: ExecCommand
284  * @tc.desc: Verify the "aa test -s class" command.
285  */
286 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1100, Function | MediumTest | Level1)
287 {
288     HILOG_INFO("Ability_Command_Test_1100 is called");
289     char *argv[] = {
290         (char *)TOOL_NAME.c_str(),
291         (char *)cmd_.c_str(),
292         (char *)"-s",
293         (char *)CLASS.c_str(),
294     };
295     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
296 
297     AbilityManagerShellCommand cmd(argc, argv);
298     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
299 }
300 
301 /**
302  * @tc.number: Ability_Command_Test_1200
303  * @tc.name: ExecCommand
304  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittest" command.
305  */
306 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1200, Function | MediumTest | Level1)
307 {
308     HILOG_INFO("Ability_Command_Test_1200 is called");
309     char *argv[] = {
310         (char *)TOOL_NAME.c_str(),
311         (char *)cmd_.c_str(),
312         (char *)"-b",
313         (char *)STRING_BUNDLENAME.c_str(),
314         (char *)"-s",
315         (char *)UNITTEST.c_str(),
316     };
317     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
318 
319     AbilityManagerShellCommand cmd(argc, argv);
320     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
321 }
322 
323 /**
324  * @tc.number: Ability_Command_Test_1300
325  * @tc.name: ExecCommand
326  * @tc.desc: Verify the "aa test -b com.example.myapplication -s class" command.
327  */
328 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1300, Function | MediumTest | Level1)
329 {
330     HILOG_INFO("Ability_Command_Test_1300 is called");
331     char *argv[] = {
332         (char *)TOOL_NAME.c_str(),
333         (char *)cmd_.c_str(),
334         (char *)"-b",
335         (char *)STRING_BUNDLENAME.c_str(),
336         (char *)"-s",
337         (char *)CLASS.c_str(),
338     };
339     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
340 
341     AbilityManagerShellCommand cmd(argc, argv);
342     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
343 }
344 
345 /**
346  * @tc.number: Ability_Command_Test_1400
347  * @tc.name: ExecCommand
348  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittest JSUserTestRunner" command.
349  */
350 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1400, Function | MediumTest | Level1)
351 {
352     HILOG_INFO("Ability_Command_Test_1400 is called");
353     char *argv[] = {
354         (char *)TOOL_NAME.c_str(),
355         (char *)cmd_.c_str(),
356         (char *)"-b",
357         (char *)STRING_BUNDLENAME.c_str(),
358         (char *)"-s",
359         (char *)UNITTEST.c_str(),
360         (char *)STRING_USER_TESTRUNNER.c_str(),
361     };
362     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
363 
364     AbilityManagerShellCommand cmd(argc, argv);
365     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
366 }
367 
368 /**
369  * @tc.number: Ability_Command_Test_1500
370  * @tc.name: ExecCommand
371  * @tc.desc: Verify the "aa test -b com.example.myapplication -s class
372  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010" command.
373  */
374 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1500, Function | MediumTest | Level1)
375 {
376     HILOG_INFO("Ability_Command_Test_1500 is called");
377     char *argv[] = {
378         (char *)TOOL_NAME.c_str(),
379         (char *)cmd_.c_str(),
380         (char *)"-b",
381         (char *)STRING_BUNDLENAME.c_str(),
382         (char *)"-s",
383         (char *)CLASS.c_str(),
384         (char *)STRING_CLASS_NAME.c_str(),
385     };
386     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
387 
388     AbilityManagerShellCommand cmd(argc, argv);
389     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
390 }
391 
392 /**
393  * @tc.number: Ability_Command_Test_1600
394  * @tc.name: ExecCommand
395  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittst JSUserTestRunner -s class
396  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
397  */
398 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1600, Function | MediumTest | Level1)
399 {
400     HILOG_INFO("Ability_Command_Test_1600 is called");
401     char *argv[] = {
402         (char *)TOOL_NAME.c_str(),
403         (char *)cmd_.c_str(),
404         (char *)"-b",
405         (char *)STRING_BUNDLENAME.c_str(),
406         (char *)"-s",
407         (char *)UNITTEST.c_str(),
408         (char *)STRING_USER_TESTRUNNER.c_str(),
409         (char *)"-s",
410         (char *)CLASS.c_str(),
411         (char *)STRING_CLASS_NAME.c_str(),
412         (char *)"-w",
413         (char *)TIME.c_str(),
414     };
415     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
416 
417     AbilityManagerShellCommand cmd(argc, argv);
418 
419     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
420 }
421 
422 /**
423  * @tc.number: Ability_Command_Test_1700
424  * @tc.name: ExecCommand
425  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittst JSUserTestRunner -s class
426  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w" command.
427  */
428 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1700, Function | MediumTest | Level1)
429 {
430     HILOG_INFO("Ability_Command_Test_1700 is called");
431     char *argv[] = {
432         (char *)TOOL_NAME.c_str(),
433         (char *)cmd_.c_str(),
434         (char *)"-b",
435         (char *)STRING_BUNDLENAME.c_str(),
436         (char *)"-s",
437         (char *)UNITTEST.c_str(),
438         (char *)STRING_USER_TESTRUNNER.c_str(),
439         (char *)"-s",
440         (char *)CLASS.c_str(),
441         (char *)STRING_CLASS_NAME.c_str(),
442         (char *)"-w",
443     };
444     int argc = sizeof(argv) / sizeof(argv[0]);
445 
446     AbilityManagerShellCommand cmd(argc, argv);
447     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
448 }
449 
450 /**
451  * @tc.number: Ability_Command_Test_1800
452  * @tc.name: ExecCommand
453  * @tc.desc: Verify the "aa test -b com.example.myapplication1 -s unittst JSUserTestRunner -s class
454  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
455  */
456 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1800, Function | MediumTest | Level1)
457 {
458     HILOG_INFO("Ability_Command_Test_1800 is called");
459     char *argv[] = {
460         (char *)TOOL_NAME.c_str(),
461         (char *)cmd_.c_str(),
462         (char *)"-b",
463         (char *)STRING_PACKAGENAME1.c_str(),
464         (char *)"-s",
465         (char *)UNITTEST.c_str(),
466         (char *)STRING_USER_TESTRUNNER.c_str(),
467         (char *)"-s",
468         (char *)CLASS.c_str(),
469         (char *)STRING_CLASS_NAME.c_str(),
470         (char *)"-w",
471         (char *)"20",
472     };
473     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
474 
475     AbilityManagerShellCommand cmd(argc, argv);
476     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
477 }
478 
479 /**
480  * @tc.number: Ability_Command_Test_1900
481  * @tc.name: ExecCommand
482  * @tc.desc: Verify the "aa test -b com.example.myapplication1 -s unittst1 JSUserTestRunner -w 20" command.
483  */
484 HWTEST_F(AbilityCommandTest, Ability_Command_Test_1900, Function | MediumTest | Level1)
485 {
486     HILOG_INFO("Ability_Command_Test_1900 is called");
487     char *argv[] = {
488         (char *)TOOL_NAME.c_str(),
489         (char *)cmd_.c_str(),
490         (char *)"-b",
491         (char *)STRING_PACKAGENAME1.c_str(),
492         (char *)"-s",
493         (char *)UNITTEST1.c_str(),
494         (char *)STRING_USER_TESTRUNNER.c_str(),
495         (char *)"-s",
496         (char *)CLASS.c_str(),
497         (char *)STRING_CLASS_NAME.c_str(),
498         (char *)"-w",
499         (char *)"20",
500     };
501     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
502 
503     AbilityManagerShellCommand cmd(argc, argv);
504     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
505 }
506 
507 /**
508  * @tc.number: Ability_Command_Test_2000
509  * @tc.name: ExecCommand
510  * @tc.desc: Verify the "aa test -b com.example.myapplication1 -s unittst1 JSUserTestRunner -s class
511  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010" command.
512  */
513 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2000, Function | MediumTest | Level1)
514 {
515     HILOG_INFO("Ability_Command_Test_2000 is called");
516     char *argv[] = {
517         (char *)TOOL_NAME.c_str(),
518         (char *)cmd_.c_str(),
519         (char *)"-b",
520         (char *)STRING_PACKAGENAME1.c_str(),
521         (char *)"-s",
522         (char *)UNITTEST1.c_str(),
523         (char *)STRING_USER_TESTRUNNER.c_str(),
524     };
525     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
526 
527     AbilityManagerShellCommand cmd(argc, argv);
528     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
529 }
530 
531 /**
532  * @tc.number: Ability_Command_Test_2100
533  * @tc.name: ExecCommand
534  * @tc.desc: Verify the "aa test -p1 com.example.myapplication -s unittst1 JSUserTestRunner -s class
535  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
536  */
537 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2100, Function | MediumTest | Level1)
538 {
539     HILOG_INFO("Ability_Command_Test_2100 is called");
540     char *argv[] = {
541         (char *)TOOL_NAME.c_str(),
542         (char *)cmd_.c_str(),
543         (char *)"-b1",
544         (char *)STRING_BUNDLENAME.c_str(),
545         (char *)"-s",
546         (char *)UNITTEST.c_str(),
547         (char *)STRING_USER_TESTRUNNER.c_str(),
548         (char *)"-s",
549         (char *)CLASS.c_str(),
550         (char *)STRING_CLASS_NAME.c_str(),
551         (char *)"-w",
552         (char *)TIME.c_str(),
553     };
554     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
555 
556     AbilityManagerShellCommand cmd(argc, argv);
557     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
558 }
559 
560 /**
561  * @tc.number: Ability_Command_Test_2200
562  * @tc.name: ExecCommand
563  * @tc.desc: Verify the "aa test -p1 com.example.myapplication -s1 unittst1 JSUserTestRunner -s class
564  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
565  */
566 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2200, Function | MediumTest | Level1)
567 {
568     HILOG_INFO("Ability_Command_Test_2200 is called");
569     char *argv[] = {
570         (char *)TOOL_NAME.c_str(),
571         (char *)cmd_.c_str(),
572         (char *)"-b",
573         (char *)STRING_BUNDLENAME.c_str(),
574         (char *)"-s1",
575         (char *)UNITTEST.c_str(),
576         (char *)STRING_USER_TESTRUNNER.c_str(),
577         (char *)"-s",
578         (char *)CLASS.c_str(),
579         (char *)STRING_CLASS_NAME.c_str(),
580         (char *)"-w",
581         (char *)TIME.c_str(),
582     };
583     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
584 
585     AbilityManagerShellCommand cmd(argc, argv);
586     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
587 }
588 
589 /**
590  * @tc.number: Ability_Command_Test_2300
591  * @tc.name: ExecCommand
592  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittst JSUserTestRunner -s class
593  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
594  */
595 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2300, Function | MediumTest | Level1)
596 {
597     HILOG_INFO("Ability_Command_Test_2300 is called");
598     char *argv[] = {
599         (char *)TOOL_NAME.c_str(),
600         (char *)cmd_.c_str(),
601         (char *)"-b",
602         (char *)STRING_BUNDLENAME.c_str(),
603         (char *)"-p",
604         (char *)STRING_PACKAGENAME.c_str(),
605         (char *)"-m",
606         (char *)STRING_MODULENAME.c_str(),
607         (char *)"-s",
608         (char *)UNITTEST.c_str(),
609         (char *)STRING_USER_TESTRUNNER.c_str(),
610         (char *)"-s",
611         (char *)CLASS.c_str(),
612         (char *)STRING_CLASS_NAME.c_str(),
613         (char *)"-w",
614         (char *)TIME.c_str(),
615     };
616     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
617 
618     AbilityManagerShellCommand cmd(argc, argv);
619     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
620 }
621 
622 /**
623  * @tc.number: Ability_Command_Test_2400
624  * @tc.name: ExecCommand
625  * @tc.desc: Verify the "aa test -b com.example.myapplication -b -s unittst JSUserTestRunner -s class
626  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
627  */
628 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2400, Function | MediumTest | Level1)
629 {
630     HILOG_INFO("Ability_Command_Test_2400 is called");
631     char *argv[] = {
632         (char *)TOOL_NAME.c_str(),
633         (char *)cmd_.c_str(),
634         (char *)"-b",
635         (char *)STRING_BUNDLENAME.c_str(),
636         (char *)"-p",
637         (char *)"-m",
638         (char *)STRING_MODULENAME.c_str(),
639         (char *)"-s",
640         (char *)UNITTEST.c_str(),
641         (char *)STRING_USER_TESTRUNNER.c_str(),
642         (char *)"-s",
643         (char *)CLASS.c_str(),
644         (char *)STRING_CLASS_NAME.c_str(),
645         (char *)"-w",
646         (char *)TIME.c_str(),
647     };
648     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
649 
650     AbilityManagerShellCommand cmd(argc, argv);
651     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
652 }
653 
654 /**
655  * @tc.number: Ability_Command_Test_2500
656  * @tc.name: ExecCommand
657  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittst JSUserTestRunner -s class
658  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
659  */
660 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2500, Function | MediumTest | Level1)
661 {
662     HILOG_INFO("Ability_Command_Test_2500 is called");
663     char *argv[] = {
664         (char *)TOOL_NAME.c_str(),
665         (char *)cmd_.c_str(),
666         (char *)"-b",
667         (char *)STRING_BUNDLENAME.c_str(),
668         (char *)"-p",
669         (char *)STRING_PACKAGENAME.c_str(),
670         (char *)"-m",
671         (char *)"-s",
672         (char *)UNITTEST.c_str(),
673         (char *)STRING_USER_TESTRUNNER.c_str(),
674         (char *)"-s",
675         (char *)CLASS.c_str(),
676         (char *)STRING_CLASS_NAME.c_str(),
677         (char *)"-w",
678         (char *)TIME.c_str(),
679     };
680     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
681 
682     AbilityManagerShellCommand cmd(argc, argv);
683     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
684 }
685 
686 /**
687  * @tc.number: Ability_Command_Test_2600
688  * @tc.name: ExecCommand
689  * @tc.desc: Verify the "aa test -b com.example.myapplication -s unittst JSUserTestRunner -s class
690  *           ohos.acts.aafwk.ability.test.ConstructorTest#testDataAbilityOtherFunction0010 -w 20" command.
691  */
692 HWTEST_F(AbilityCommandTest, Ability_Command_Test_2600, Function | MediumTest | Level1)
693 {
694     HILOG_INFO("Ability_Command_Test_2600 is called");
695     char *argv[] = {
696         (char *)TOOL_NAME.c_str(),
697         (char *)cmd_.c_str(),
698         (char *)"-b",
699         (char *)STRING_BUNDLENAME.c_str(),
700         (char *)"-p",
701         (char *)STRING_PACKAGENAME.c_str(),
702         (char *)"-m",
703         (char *)STRING_MODULENAME.c_str(),
704         (char *)"-s",
705         (char *)UNITTEST.c_str(),
706         (char *)STRING_USER_TESTRUNNER.c_str(),
707         (char *)"-s",
708         (char *)CLASS.c_str(),
709         (char *)STRING_CLASS_NAME.c_str(),
710         (char *)"-s",
711         (char *)"-w",
712         (char *)TIME.c_str(),
713     };
714     int argc = sizeof(argv) / sizeof(argv[0]) - 1;
715 
716     AbilityManagerShellCommand cmd(argc, argv);
717     EXPECT_EQ(cmd.RunAsTestCommand(), OHOS::ERR_INVALID_VALUE);
718 }
719