2

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

Manish Doshi
  • 1,205
  • 1
  • 9
  • 17
Kirill Kulakov
  • 10,035
  • 9
  • 50
  • 67

3 Answers3

3

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

Community
  • 1
  • 1
Marco Corona
  • 812
  • 6
  • 12
1

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

Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
1

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.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134