简体   繁体   中英

Eclipse Java Unit tests

Is there a way to execute batch script before each unit-test? 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

If you are using JUnit, annotate a class with the @before tag and that class will be executed before every test case. In order to run a script look at this post

Here a short summary of the some usefull annotations in junit:

JUnit 4 führt sechs unterschiedliche Annotationen ein:

@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

When you run Android JUnit tests they are run on the device or emulator via the test runner.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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