How can I skip tests in maven install goal, while running them in maven test goal?

It sounds like you didn’t understand the concept of the build life-cycle in Maven. If you run mvn install all life-cycle phases (including the install phase itself) run before the install phase. This means running the following phases: validate initialize generate-sources process-sources generate-resources process-resources compile process-classes generate-test-sources process-test-sources generate-test-resources process-test-resources test-compile process-test-classes test prepare-package package … Read more

How to write unit tests for database calls

What are you testing? There are three possibilities, off the top of my head: A. You’re testing the DAO (data access object) class, making sure it’s correctly marshaling the values/parameters being passed to the database,, and correctly marshaling/transforming/packaging results gotten frm the database. In this case, you don’t need to connect to the database at … Read more

How do you test an Android application across multiple Activities?

I feel a bit awkward about answering my own bounty question, but here it is… I’ve searched high and low on this and can’t believe there is no answer published anywhere. I have come very close. I can definitely run tests that span activities now, but my implementation seems to have some timing issues where … Read more

Difference between MockMvc and RestTemplate in integration tests

As said in this article you should use MockMvc when you want to test Server-side of application: Spring MVC Test builds on the mock request and response from spring-test and does not require a running servlet container. The main difference is that actual Spring MVC configuration is loaded through the TestContext framework and that the … Read more

Before and After Suite execution hook in jUnit 4.x

Yes, it is possible to reliably run set up and tear down methods before and after any tests in a test suite. Let me demonstrate in code: package com.test; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({Test1.class, Test2.class}) public class TestSuite { @BeforeClass public static void setUp() { System.out.println(“setting up”); } … Read more

Difference between Android Instrumentation test and Unit test in Android Studio?

It seems to me that instrumentation testing is integration testing with the ability to control the life cycle and the events (onStart, onCreate etc) of the app. Unit testing, as i understand it, is testing a Unit (eg Class) for its data and behavior. For example, say you have a game: this game runs on … Read more

How are integration tests written for interacting with external API?

This is more an additional answer to the one already given: Looking through your code, the class GoogleAPIRequest has a hard-encoded dependency of class Request. This prevents you from testing it independently from the request class, so you can’t mock the request. You need to make the request injectable, so you can change it to … Read more