diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/GlobalContext.ts b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/GlobalContext.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a0a885f3e2610c79645c247880b0675dc905ad8 --- /dev/null +++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/GlobalContext.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {Core} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" + +export default class GlobalContext { + constructor(){ + } + globalContext(core:Core) { + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + } +} \ No newline at end of file diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets index 9917acdeae8f18df41910e6f52b13075bd8ec99d..a07d7d96fc47571da6e55f34ebf286b9bcdb1e10 100644 --- a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets +++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets @@ -15,30 +15,27 @@ import file from '@system.file'; import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" -import testsuite from "../../test/List.test.ets" +import GlobalContext from "../MainAbility/GlobalContext.ts" @Entry @Component struct Index { - aboutToAppear(){ console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' + const core:Core = Core.getInstance() + const expectExtend:ExpectExtend = new ExpectExtend({ + id: 'extend' }) core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) + const reportExtend:ReportExtend = new ReportExtend(file) core.addService('report', reportExtend) core.init() core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - globalThis.abilityWant.parameters.timeout = 70000; - configService.setConfig(globalThis.abilityWant.parameters) - testsuite(globalThis.abilityContext) + + const globalContext:GlobalContext = new GlobalContext() + globalContext.globalContext(core) core.execute() } diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets index 3e6bb1b0df3d58e322a8573c7ba1016c5f53fcae..e1e14f881f2ce231f48f61f3f7fab1b65829140f 100644 --- a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets +++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets @@ -14,5 +14,5 @@ */ -export default function testsuite(context) { +export default function testsuite(context:Context) { } \ No newline at end of file