NativeScript / NativeScript/nativescript-cli

Extended Android Activity crashes unit-test-runner

未关闭
#5,608 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

os: android unit testing
主要语言
JavaScript
星标
1.1k
派生
204
平均合并
1 天 9 小时
30 天内合并 PR
8

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 ns create ns-test --ts、一个扩展的 Android activity、ns test initns test android 重现崩溃。首先跟踪 nativescript-unit-test-runner 如何覆盖 webpack 并解析 activity.android.ts;当存在扩展的 Android activity 时单元测试能够成功运行,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, javascript, typescript
领域
cli, mobile, testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。