diff --git a/README.md b/README.md index 457c9cf..70f5320 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ #goadb -[![Build Status](https://travis-ci.org/zach-klippenstein/goadb.svg?branch=master)](https://travis-ci.org/zach-klippenstein/goadb) [![GoDoc](https://godoc.org/github.com/zach-klippenstein/goadb?status.svg)](https://godoc.org/github.com/zach-klippenstein/goadb) +Unit Tests: [![Build Status](https://travis-ci.org/zach-klippenstein/goadb.svg?branch=master)](https://travis-ci.org/zach-klippenstein/goadb) + +Integration Tests: [![Circle CI](https://circleci.com/gh/zach-klippenstein/goadb.svg?style=shield)](https://circleci.com/gh/zach-klippenstein/goadb) + A Golang library for interacting with the Android Debug Bridge (adb). See [demo.go](cmd/demo/demo.go) for usage. diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..0eed1db --- /dev/null +++ b/circle.yml @@ -0,0 +1,26 @@ +# +# Build configuration for Circle CI +# + +machine: + environment: + GO15VENDOREXPERIMENT: 1 + ANDROID_HOME: /usr/local/android-sdk-linux + +dependencies: + post: + - go get -u github.com/jstemmer/go-junit-report + +test: + pre: + - go version + - emulator -avd circleci-android23 -no-audio -no-window: + background: true + parallel: true + - circle-android wait-for-boot + + override: + # Circle requires test results to be in JUnit's XML format. + - mkdir -p $CIRCLE_TEST_REPORTS/junit + - go test -v ./internal/integrationtests/... | go-junit-report > $CIRCLE_TEST_REPORTS/junit/test-results.xml: + timeout: 600 diff --git a/internal/integrationtests/integration_test.go b/internal/integrationtests/integration_test.go new file mode 100644 index 0000000..1565f40 --- /dev/null +++ b/internal/integrationtests/integration_test.go @@ -0,0 +1,34 @@ +package integrationtests + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/zach-klippenstein/goadb" +) + +func TestListDevices(t *testing.T) { + server, err := adb.NewServer(adb.ServerConfig{}) + require.NoError(t, err) + client := adb.NewHostClient(server) + + devices, err := client.ListDevices() + require.NoError(t, err) + assert.Len(t, devices, 1) + t.Logf("Found %d devices:", len(devices)) + for _, device := range devices { + t.Logf("%s\tusb:%s product:%s model:%s device:%s\n", + device.Serial, device.Usb, device.Product, device.Model, device.DeviceInfo) + } +} + +func TestShell(t *testing.T) { + server, err := adb.NewServer(adb.ServerConfig{}) + require.NoError(t, err) + client := adb.NewDeviceClient(server, adb.AnyDevice()) + + output, err := client.RunCommand("echo", "hello world") + require.NoError(t, err) + require.Equal(t, "hello world", output) +}