2
votes

I have been spending a lot of time trying to figure out how to run unit test in TeamCity. I have an android studio project and inside this project directory (app/src/test/java/com...), there is a java file named "ExampleUnitTest". Here is the code snippet:

  public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
    assertEquals(45, 2 + 2);
}

@Test
public void checkString()
{
    assertEquals("hardy","putra");
}

}

I can run the unit test from the android studio by right click on this java file and click run, but I wanna do it in TeamCity. How to do that? Can someone save my life and tell me how to do it please???

Here is the screenshot of the build steps I configured in TeamCity. enter image description here

Running this build step will not run any unit test in the TeamCity, but will tell me that my build is passed. I tried using maven etc. but I still do not really understand. Can someone save my life and tell me what I should do to my build step in order to run unit test? Thank you so much :)

UPDATE: I checked the checkbox "Use gradle wrapper to build project" but it still could not run the unit test. Is something wrong with my understanding of unit test in teamcity? Please point me to the right direction.

Here is the screenshot of the result after checking the checkbox "Use gradle wrapper to build project" and run it.

enter image description here

1
What if you tick the box "Use gradle wrapper to build project"?Michael Dodd

1 Answers

0
votes

The only thing that looks wrong in the above screenshot is that you don't have the Use gradle wrapper to build project box ticked. Tick this as this will ensure that you'll be using the same version of Gradle as Android Studio.