frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

DevEco Testing: Official Automation Testing Tool for HarmonyOS Applications

1•moyantianwang•1d ago
# DevEco Testing: Official Automation Testing Tool for HarmonyOS Applications

 

> These notes provide a high-level overview and may contain inaccuracies. For detailed information, please refer to the official documentation.

## 1. Test Framework Architecture

DevEco Testing is built on the JUnit5 extension mechanism and adopts a layered testing strategy:

1. Unit Testing Layer: Covers business logic components (Service/Manager)

2. Component Testing Layer: Validates Ability/Extension functionalities

3. System Testing Layer: Verifies multi-device collaborative scenarios

Core capabilities include:

* ArkTS Test Engine: Supports asynchronous task validation

* Device Shadow Mode: Simulates multi-device collaborative environments

* Data Sandbox: Isolates test data from production environments

## 2. Unit Testing Implementation

### 1. Test Case Specifications

``` typescript ```

``` // Example: Asynchronous Task Validation @Test async function testAsyncTask() { const result = await DataService.fetchData(); assertEquals(result.code, 200); assertTrue(Array.isArray(result.data)); } ```

### 2. Mock Service Configuration

Dependency isolation using @Mock annotations:

``` typescript ```

``` // Mock network service @Mock class NetworkService { @InjectMock async fetchData(): Promise<Data> { return { code: 200, data: mockData }; } } ```

### 3. Test Coverage

Line-level coverage reporting:

``` markdown ```

``` ------------------------- Test Coverage Report ------------------------- Module | Line Coverage | Branch Coverage ----------------------------------------------- CoreService | 82% | 75% UIComponent | 91% | 88% NetworkModule | 67% | 63% ```

## 3. UI Automation Testing

### 1. Component Localization Strategies

| Strategy | Use Case | Example Code | | :---------- | :----------------------- | :-------------------------------------------- | | resource-id | Stable element ID | component.findComponentById('btn_submit') | | text | Dynamic content matching | component.findComponentsByText('Submit') | | xpath | Complex hierarchy | component.findByXPath('//[@text="Confirm"]') |

### 2. Gesture Simulation

``` typescript ```

``` // Swipe Operation Example test('Swipe Test', async () => { await gesture.swipe({ startX: 500, startY: 1500, endX: 500, endY: 500, duration: 800 }); await expect(component).toHaveText('New Content'); }); ```

### 3. Exception Scenarios

Network fluctuation simulation: device.simulateNetwork('3G')

* Memory pressure testing: device.fillMemory(80%)

* Low battery testing: device.setBatteryLevel(15%)

## 4. CI/CD Integration

### 1. Pipeline Configuration

``` yaml ```

``` # devops-ci.yaml stages: - name: unit-test script: - npm run build - npm run test:unit -- --coverage

  - name: ui-test
    device:
      type: emulator
      config: phone_2k
    script:
      - npm run test:ui -- --headless
```

### 2. Test Reporting

Output formats:

``` bash ```

``` test-results/ ├── junit.xml # CI system integration └── report.html # Visual analysis report ```

##

BioNTech and Bristol Myers Squibb Announce Global Strategic Partnership

https://investors.biontech.de/news-releases/news-release-details/biontech-and-bristol-myers-squibb-announce-global-strategic/
1•doener•1m ago•0 comments

Show HN: Client side rendered static site without JavaScript

https://www.cornerlation.xyz
1•imcotton•6m ago•0 comments

FEMA staff baffled after head said he was unaware of US hurricane season

https://www.reuters.com/world/us/fema-staff-confused-after-head-said-he-was-unaware-us-hurricane-season-sources-2025-06-02/
14•nabla9•8m ago•0 comments

Google settles a major antitrust lawsuit – but it's not the one making headlines

https://www.phonearena.com/news/google-settles-a-major-antitrust-lawsuit--but-its-not-the-one-making-headlines_id170944
1•mikece•8m ago•0 comments

Python deserves better than EMR

https://docs.coiled.io/blog/python-emr.html
1•scj13•9m ago•0 comments

I Like Big Batches and I Cannot Lie: Tricks for Good Embeddings

https://www.nuss-and-bolts.com/p/i-like-big-batches-and-i-cannot-lie
2•zanussbaum•10m ago•0 comments

NLWeb: Microsoft's Protocol for AI-Powered Website Search

https://glama.ai/blog/2025-06-01-what-is-nlweb
4•punkpeye•10m ago•0 comments

Floating Nuclear Data Centers to Power AI Revolution at Sea

https://gcaptain.com/abs-charts-course-for-floating-nuclear-data-centers-to-power-ai-revolution-at-sea/
1•mikece•17m ago•0 comments

Japan's Recent Rice Price Crisis [video]

https://www.youtube.com/watch?v=l4vTQV3HjKU
1•lawrenceyan•19m ago•0 comments

Cloud of Sahara dust is smothering the Caribbean en route to the US

https://apnews.com/article/sahara-dust-caribbean-florida-barbados-jamaica-plume-e0aafba9fe672b832559606e499e1280
1•geox•19m ago•0 comments

Ask HN: What is our history on trying to standardize configuration languages?

2•jerrac•20m ago•2 comments

Teaching Program Verification in Dafny at Amazon (2023)

https://dafny.org/blog/2023/12/15/teaching-program-verification-in-dafny-at-amazon/
1•Jtsummers•21m ago•0 comments

I Made a Puzzle Game

https://geonot.github.io/korokoro/
4•wildlogic•24m ago•2 comments

Saw a guy coding today. No cursor. No windsurf. Just typing. Like a psychopath

https://texttoslides.ai/blog/coding-without-ai
3•sh_tomer•25m ago•0 comments

Show HN: ChatDelta

https://github.com/ChatDelta/ChatDelta
1•DavidCanHelp•26m ago•0 comments

Bureaucracy (2024)

https://neil.fraser.name/news/2024/12/19/
2•ColinWright•27m ago•0 comments

Texas Right to Repair bill passes, heads to the governor's desk

https://www.theverge.com/law/678334/right-to-repair-texas-hb-2963
3•mikece•30m ago•0 comments

Conformance Checking at MongoDB: Testing That Our Code Matches Our TLA+ Specs

https://www.mongodb.com/blog/post/engineering/conformance-checking-at-mongodb-testing-our-code-matches-our-tla-specs
13•todsacerdoti•34m ago•0 comments

Kubesolo.io, a special purpose Kubernetes distribution for IoT Devices

https://www.kubesolo.io/about
2•neilcresswell•35m ago•1 comments

Open Desk View

https://sannysanoff.github.io/whiteboard/
1•sannysanoff•35m ago•1 comments

Automated ML research, AI drives the process from idea to report

https://killerstorm.github.io/2025/05/31/automl.html
3•killerstorm•37m ago•0 comments

Hardening fixes lead to hard questions

https://lwn.net/SubscriberLink/1023502/8a46fb7ef3630140/
4•jacobo37•37m ago•0 comments

Demo of kons-9 Common Lisp 3D graphics system [video]

https://www.youtube.com/watch?v=TjbYFaNAspw
6•kaveh808•39m ago•0 comments

Dev snapshot: Godot 4.5 dev 5

https://godotengine.org/article/dev-snapshot-godot-4-5-dev-5/
2•kelseyfrog•39m ago•0 comments

Japanese Scientists Develop Artificial Blood Compatible with All Blood Types

https://www.tokyoweekender.com/entertainment/tech-trends/japanese-scientists-develop-artificial-blood/
10•Geekette•40m ago•3 comments

The Oracle of Lexiconia – A Fantasy That Explains How LLMs Work

https://medium.com/@isranimohit/the-oracle-of-lexiconia-a-fantasy-story-that-teaches-you-how-ai-understands-language-0c063f836057
2•isranimohit•42m ago•1 comments

Forge – an advanced 3D Gaussian Splatting renderer for Three.js

https://forge.dev/
10•Tycho87•42m ago•0 comments

Street Fighter 2 composer Yoko Shimomura has created a new track for SF6

https://www.videogameschronicle.com/news/street-fighter-2-composer-yoko-shimomura-has-created-a-new-song-for-sf6-returning-to-the-series-after-30-years/
1•mikhael•45m ago•0 comments

Tests should not contain logic

https://blog.snork.dev/posts/tests-should-not-contain-logic.html
1•todsacerdoti•48m ago•0 comments

Tech-bro satire Mountainhead is an insufferable disappointment

https://www.theguardian.com/tv-and-radio/2025/jun/02/mountainhead-tech-bro-satire-disappointment
3•labrador•50m ago•2 comments