简体   繁体   English

Eclipse Java单元测试

[英]Eclipse Java Unit tests

Is there a way to execute batch script before each unit-test? 有没有一种方法可以在每次单元测试之前执行batch脚本? I've looked up the launch options for the test project, but I couldn't find any way to run any script 我已经查看了测试项目的启动选项,但是找不到任何运行脚本的方法

the script is a single line, which should be able to interface the android via adb 该脚本是一行,应该能够通过adb与android接口

If you are using JUnit, annotate a class with the @before tag and that class will be executed before every test case. 如果使用的是JUnit,请使用@before标记注释一个类,该类将在每个测试用例之前执行。 In order to run a script look at this post 为了运行脚本,请看这篇文章

Here a short summary of the some usefull annotations in junit: 这是junit中一些有用注释的简短摘要:

JUnit 4 führt sechs unterschiedliche Annotationen ein: JUnit 4注释:

@Test - kennzeichnet Methoden als ausführbare Testfälle.
@Before und @After - markieren Setup- bzw. Teardown-Aufgaben, die für jeden Testfall wiederholt werden sollen.
@BeforeClass und @AfterClass - markieren Setup- bzw. Teardown-Aufgaben, die nur einmal pro Testklasse ausgeführt werden sollen.
@Ignore - kennzeichnet temporär nicht auszuführende Testfälle.

Source: http://www.frankwestphal.de/JUnit4.0.html 资料来源: http : //www.frankwestphal.de/JUnit4.0.html

When you run Android JUnit tests they are run on the device or emulator via the test runner. 当您运行Android JUnit测试时,它们将通过测试运行程序在设备或仿真器上运行。

So if you try to run a script inside your JUnit tests it will also be run on the device or emulator, which is most probably not your intention. 因此,如果您尝试在JUnit测试中运行脚本,则该脚本也将在设备或仿真器上运行,这很可能不是您的意图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM