是否可以从 Web 浏览器获取运行测试的 GWT Web 应用程序的代码覆盖率数据?

发布于 2024-08-26 17:33:27 字数 241 浏览 4 评论 0原文

我不确定这是否可行,但我想要某种方法来获取在快速测试中为基于 GWT 的 Web 应用程序编写的测试的代码覆盖率信息。

似乎没有任何解决方案,因为 Quick Test Pro 测试是针对 GWT 编译的应用程序进行测试,而不是针对编写应用程序的原始 java 代码进行测试。我想我可以获得 GWT 编译器创建的 javascript 的覆盖率数据,但我(据我所知)无法将此信息映射回原始 java 代码。

有什么方法可以做到这一点吗?

I am not sure if this is possible but I would like some way to get code coverage information for tests that are written in Quick Test for our GWT based web app.

It does not seem like there is any solution because the Quick Test Pro tests are testing against the GWT compiled app and not the original java code in which the app was written. I suppose I could get coverage data on the javascript that the GWT compiler creates, but there would be no way for me (that I know of) to map this information back to the original java code.

Is there some way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嗫嚅 2024-09-02 17:33:27

否,因为您不想测试 GWT(或 GWT 编译器):您想测试您自己的代码。因此,您应该通过正常的单元测试获得良好的覆盖范围,并仅测试无法通过快速测试这种方式测试的内容。

No because you don't want to test GWT (or the GWT compiler): You want to test your own code. So you should get a good coverage with normal unit tests and only test what you can't test this way with Quick Test.

德意的啸 2024-09-02 17:33:27

如果我理解这个问题,您使用 Java 进行编码,GWT 将其转换为 JavaScript,并且您想要通过运行 GWT 编译器版本获得有关 Java 程序的覆盖信息?

如果是的话,有一个方法可以做到。我们的 SD Java 测试覆盖率工具使用 Java 源代码来收集其覆盖率数据。

如果您运行我们的 SD 测试覆盖率工具,您将获得经过检测的 Java 代码。如果您使用 GWT 编译并运行该程序,该工具仍然会收集数据,就像程序作为 Java 运行一样

仪器在运行时构建一个简单的布尔数组。通常,它会在“退出”时由已检测的 Java 程序转储到文件中(对于“退出”的各种定义)。转储逻辑非常简单(循环数组并写入值)并且可自定义。编写 Javascript 代码的等效内容应该非常容易。

通过导出的检测数据,我们的 SD Java 测试覆盖率工具将在原始源代码上显示您的测试覆盖率,就像您执行了 Java 代码本身一样。而且它会是准确的。

If I understand the problem, you code in Java, GWT translates that to JavaScript, and you want coverage information on the Java program obtained from running the GWT-compiler version?

If so, there's a way to do it. Our SD Java Test Coverage tool instruments Java source code to collect its coverage data.

If you ran our SD test coverage tool, what you get is instrumented Java code. If you compile and run that with GWT, the instrumentation will still collect the data as if the program were running as Java.

The instrumentation builds a trivial array of booleans at runtime. Normally that is dumped by the instrumented Java program to a file as it "exits" (for a variety of definitions of "exit"). The dump logic is pretty trivial (loop over the array and write the values) and customizable. Writing the equivalent for the Javascript code should be pretty easy.

With the exported instrumentation data, our SD Java Test Coverage tool will display your test coverage, on your original source code, as though you had executed the Java code itself. And it will be accurate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文