From 22616c1d07b141fb8d7f3572a9ae9658f3c6e744 Mon Sep 17 00:00:00 2001 From: Lotol Date: Fri, 24 Nov 2023 09:30:03 +0000 Subject: [PATCH] =?UTF-8?q?arkTs=E5=91=8A=E8=AD=A6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lotol Change-Id: I835c76333aef4a45d9775ff3c6e2d58d2ecdaad1 --- .../src/main/ets/MainAbility/GlobalContext.ts | 28 +++++++++++++++++++ .../entry/src/main/ets/pages/index/index.ets | 19 ++++++------- .../entry/src/main/ets/test/List.test.ets | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/GlobalContext.ts 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 0000000..0a0a885 --- /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 9917acd..a07d7d9 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 3e6bb1b..e1e14f8 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 -- Gitee