├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── config.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── menu
│ │ │ │ └── main.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── andnexus
│ │ │ │ └── android
│ │ │ │ └── tests
│ │ │ │ ├── App.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── debug
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── andnexus
│ │ │ └── android
│ │ │ └── tests
│ │ │ ├── Graph.java
│ │ │ └── ActivityTest.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── andnexus
│ │ │ └── android
│ │ │ └── tests
│ │ │ └── MainActivityTest.java
│ ├── release
│ │ └── java
│ │ │ └── com
│ │ │ └── andnexus
│ │ │ └── android
│ │ │ └── tests
│ │ │ └── Graph.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── andnexus
│ │ └── android
│ │ └── tests
│ │ └── MainActivityTest.java
├── proguard-rules.pro
└── build.gradle
├── model
├── .gitignore
├── build.gradle
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── andnexus
│ │ └── model
│ │ └── Data.java
│ └── test
│ └── java
│ └── com
│ └── andnexus
│ └── test
│ └── model
│ └── DataTest.java
├── backend
├── .gitignore
├── build.gradle
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── andnexus
│ │ │ └── backend
│ │ │ ├── Database.java
│ │ │ ├── DataServlet.java
│ │ │ └── ResponseBuilder.java
│ └── webapp
│ │ ├── WEB-INF
│ │ └── web.xml
│ │ └── index.jsp
│ └── test
│ └── java
│ └── com
│ └── andnexus
│ └── backend
│ └── ResponseBuilderTest.java
├── connect
├── .gitignore
├── gradle.properties
├── src
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── andnexus
│ │ │ └── connect
│ │ │ ├── ConnectIntegrationTest.java
│ │ │ ├── ParserTest.java
│ │ │ ├── RequestTest.java
│ │ │ └── ConnectTest.java
│ └── main
│ │ └── java
│ │ └── com
│ │ └── andnexus
│ │ └── connect
│ │ ├── Parser.java
│ │ ├── Connect.java
│ │ └── Request.java
└── build.gradle
├── settings.gradle
├── assets
├── android-testing.gif
├── android-testing.mp4
├── java-connect-tests.png
├── java-connect-jacoco.png
└── LICENSE
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── .travis.yml
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/model/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/backend/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/connect/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':connect', ':backend', ':model'
2 |
--------------------------------------------------------------------------------
/model/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 |
3 | dependencies {
4 | testCompile "junit:junit:4.10"
5 | }
--------------------------------------------------------------------------------
/assets/android-testing.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/assets/android-testing.gif
--------------------------------------------------------------------------------
/assets/android-testing.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/assets/android-testing.mp4
--------------------------------------------------------------------------------
/assets/java-connect-tests.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/assets/java-connect-tests.png
--------------------------------------------------------------------------------
/connect/gradle.properties:
--------------------------------------------------------------------------------
1 | jettyHttpPort=8000
2 | jettyStopPort=8001
3 | jettyScanIntervalSeconds=3
4 | jettyDaemon=true
--------------------------------------------------------------------------------
/assets/java-connect-jacoco.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/assets/java-connect-jacoco.png
--------------------------------------------------------------------------------
/app/src/main/res/values/config.xml:
--------------------------------------------------------------------------------
1 |
2 | service.andnexus.com
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/andnexus/android-testing/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.apk
2 | *.ap_
3 | *.jar
4 | !gradle/wrapper/gradle-wrapper.jar
5 | lint
6 | *.dex
7 | *.class
8 | bin/
9 | gen/
10 | classes/
11 | gen-external-apklibs/
12 | target
13 | local.properties
14 | .idea
15 | *.iml
16 | .DS_Store
17 | *.swp
18 | *.bak
19 | .gradle
20 | build/
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tests
3 | No data found…
4 | No connection available…
5 | refresh
6 |
7 |
--------------------------------------------------------------------------------
/backend/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | apply plugin: 'war'
3 |
4 | dependencies {
5 |
6 | compile project(':model')
7 | compile 'org.json:json:20140107'
8 | compile 'javax.servlet:servlet-api:2.5'
9 | compile 'com.google.guava:guava:18.0'
10 |
11 | testCompile 'junit:junit:4.10'
12 | }
--------------------------------------------------------------------------------
/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/backend/src/main/java/com/andnexus/backend/Database.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.backend;
2 |
3 | import com.andnexus.model.Data;
4 |
5 | public class Database {
6 |
7 | private static final Data[] DATA = {new Data(123), new Data(456)};
8 |
9 | public Data[] getData() {
10 | return DATA;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/model/src/main/java/com/andnexus/model/Data.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.model;
2 |
3 | public class Data {
4 |
5 | private final int mId;
6 |
7 | public Data(int id) {
8 | mId = id;
9 | }
10 |
11 | @Override
12 | public String toString() {
13 | return String.format("%d", getId());
14 | }
15 |
16 | public int getId() {
17 | return mId;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/andnexus/android/tests/MainActivityTest.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.android.tests;
2 |
3 | import org.junit.Before;
4 | import org.junit.Test;
5 |
6 | import static junit.framework.Assert.assertTrue;
7 |
8 | public class MainActivityTest {
9 |
10 | @Before
11 | public void setUp() {
12 | }
13 |
14 | @Test
15 | public void should() {
16 | assertTrue(true);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/andnexus/android/tests/App.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.android.tests;
2 |
3 |
4 | import android.app.Application;
5 |
6 | public class App extends Application {
7 |
8 | private Graph mGraph;
9 |
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 |
14 | mGraph = Graph.Initializer.init(this);
15 | }
16 |
17 | public Graph graph() {
18 | return mGraph;
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/backend/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Data
5 | com.andnexus.backend.DataServlet
6 |
7 |
8 | Data
9 | /data
10 |
11 |
12 | index.jsp
13 |
14 |
--------------------------------------------------------------------------------
/backend/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 | <%@page import="java.util.Date"%>
2 | <%@ page language="java" contentType="text/html; charset=US-ASCII" pageEncoding="US-ASCII"%>
3 |
4 |
5 |
6 |
7 | Backend
8 |
9 |
10 | Backend is running.
11 |
12 | Date=<%= new Date() %>
13 |
14 |
--------------------------------------------------------------------------------
/backend/src/main/java/com/andnexus/backend/DataServlet.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.backend;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.servlet.http.HttpServlet;
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | public class DataServlet extends HttpServlet {
10 |
11 | public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
12 | resp.setContentType("application/json");
13 | resp.getWriter().println(new ResponseBuilder().setData(new Database().getData()).createJson());
14 | }
15 | }
--------------------------------------------------------------------------------
/connect/src/test/java/com/andnexus/connect/ConnectIntegrationTest.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.connect;
2 |
3 | import com.andnexus.model.Data;
4 |
5 | import org.junit.Test;
6 |
7 | import java.util.List;
8 |
9 | import static org.junit.Assert.assertEquals;
10 |
11 | public class ConnectIntegrationTest {
12 |
13 | @Test
14 | public void backendIntegrationTest() throws Exception {
15 |
16 | Connect connect = new Connect("localhost");
17 | List actual = connect.getData();
18 | assertEquals(2, actual.size());
19 | assertEquals(123, actual.get(0).getId());
20 | assertEquals(456, actual.get(1).getId());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/release/java/com/andnexus/android/tests/Graph.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.android.tests;
2 |
3 | import android.content.Context;
4 |
5 | import javax.inject.Singleton;
6 |
7 | import dagger.Component;
8 |
9 | import static com.andnexus.android.tests.MainActivity.Module;
10 |
11 | @Singleton
12 | @Component(modules = {Module.class})
13 | public interface Graph {
14 |
15 | void inject(MainActivity activity);
16 |
17 | public final static class Initializer {
18 |
19 | public static Graph init(Context context) {
20 | return DaggerGraph.builder()
21 | .module(new Module(context))
22 | .build();
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/blehejcek/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class value to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/debug/java/com/andnexus/android/tests/Graph.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.android.tests;
2 |
3 | import android.content.Context;
4 |
5 | import javax.inject.Singleton;
6 |
7 | import dagger.Component;
8 |
9 | import static com.andnexus.android.tests.ActivityTest.Module;
10 |
11 | @Singleton
12 | @Component(modules = {Module.class})
13 | public interface Graph {
14 |
15 | void inject(MainActivity activity);
16 |
17 | void inject(ActivityTest activity);
18 |
19 | public final static class Initializer {
20 |
21 | public static Graph init(Context context) {
22 | System.setProperty("dexmaker.dexcache", context.getCacheDir().getPath());
23 | return DaggerGraph.builder()
24 | .module(new Module())
25 | .build();
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/backend/src/main/java/com/andnexus/backend/ResponseBuilder.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.backend;
2 |
3 | import com.andnexus.model.Data;
4 |
5 | import org.json.JSONArray;
6 | import org.json.JSONObject;
7 |
8 | public class ResponseBuilder {
9 |
10 | private Data[] mData;
11 |
12 | public final ResponseBuilder setData(Data[] data) {
13 | mData = data;
14 | return this;
15 | }
16 |
17 | public final String createJson() {
18 | final JSONArray array = new JSONArray();
19 | if (mData != null) {
20 | for (Data item : mData) {
21 | JSONObject object = new JSONObject();
22 | object.put("id", item.getId());
23 | array.put(object);
24 | }
25 | }
26 | return new JSONObject().put("data", array).toString();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/model/src/test/java/com/andnexus/test/model/DataTest.java:
--------------------------------------------------------------------------------
1 | package com.andnexus.test.model;
2 |
3 | import com.andnexus.model.Data;
4 |
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.Parameterized;
8 |
9 | import java.util.Arrays;
10 |
11 | import static org.junit.Assert.assertEquals;
12 | import static org.junit.runners.Parameterized.Parameters;
13 |
14 | @RunWith(Parameterized.class)
15 | public class DataTest {
16 |
17 | private final Data mData;
18 |
19 | private final String mExpected;
20 |
21 | public DataTest(String expected, Data actual) {
22 | mExpected = expected;
23 | mData = actual;
24 | }
25 |
26 | @Parameters
27 | public static Iterable