NativeScript / NativeScript/nativescript-cli

Extended Android Activity crashes unit-test-runner

Open
#5,608 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

os: android unit testing
Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 8.1.4
  • Cross-platform modules: @nativescript/core 8.1.1
  • Android Runtime: 8.1.1

Describe the bug
the nativescript-unit-test-runner is overriding webpack such that the extended activity file (activity.android.ts) is not resolved causing
a crash:

...
System.err: Unable to instantiate activity ComponentInfo{org.nativescript.nstest/org.myApp.MainActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'org/myApp/MainActivity'
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nativescript.nstest/org.myApp.MainActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'org/myApp/MainActivity'
System.err: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3194)

...

To Reproduce

  1. create new app ns create ns-test --ts

  2. extend Android activity following the instructions here: https://docs.nativescript.org/advanced-concepts.html#extending-android-activity

  3. verify that the app runs as expected ns run android (the app runs without any problems)

  4. initialize tests ns test init and select jasmine

  5. run tests ns test android

  6. crash and burn

Expected behavior
That unit tests run, even in the presence of an extended android activity

Sample project
Can't, updating AndroidManifest is required

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with ns create ns-test --ts, an extended Android activity, ns test init, and ns test android. Start by tracing how the nativescript-unit-test-runner overrides webpack and resolves activity.android.ts; done means unit tests run successfully when an extended Android activity is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, typescript
Domain
cli, mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.