Skip to content

James/threadcoderevert #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 111 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,123 @@
# android-library

## ADDING MOQUALITY LIBRARY TO YOUR PROJECT'S TEST CLASSES
-------------------------------------------------------

- in your main build.gradle (Project) file, add:

### Run single test
```
allprojects {
repositories {
...

// for MoQuality library
maven {url "https://jitpack.io" }

...
]
]
```
./gradlew cAT -Pandroid.testInstrumentationRunnerArguments.class=com.moquality.android.AppTest

- under the "dependencies {" section of your build.gradle (Module) file, add:
```
// MoQuality dependencies
implementation 'com.github.moquality:android-library:master-SNAPSHOT'
testImplementation 'com.github.moquality:android-library:master-SNAPSHOT'
androidTestImplementation 'com.github.moquality:android-library:master-SNAPSHOT'
```

- in your test class, declare a private instance of the MoQuality library:

Create screenshots folder
```
adb shell
cd /sdcard/Pictures
mkdir screenshots
private MoQuality moQBot = new MoQuality();
```

Screenshots are in the Pictures/screenshots folder. Command to pull.
Add an initialize method at the top of the same class,

```
adb pull /sdcard/Pictures/screenshots .
```
@Before
public void initialize() {
String deviceId;

Bundle extras = InstrumentationRegistry.getArguments();

deviceId = extras.getString("deviceId");

Log.i(TAG, "Arguments = " + extras.toString());
Log.i(TAG, "deviceId" + deviceId);

moQBot.register(this, deviceId);
}
```

Now add the following MoQuality specific calls,

```
@Test
public void runTest() {
moQBot.runSocketIOTest();
}

@After
public void shutdown() {
moQBot.shutdown();
}
```

Next write your public test methods as normal. If you wish to capture a screen shot via the library during the test, insert the following code:

```
try {
moQBot.takeScreenshot("<optional name>");
} catch (IOException e) {
e.printStackTrace();
}
```

Finally create a JSON test script, that calls your test methods. For example,
```
[ {
"type": "espresso", <--- indicates the type of command, "espresso", "uiautomator", "devices", or "signal"
"msg":
{
"deviceId": "device1", <---- allows you to target a specific device for the test script
"cmd": "openNavDrawer", <---- reference to the exact test method name
"args": [] <--- optional cmd arguments that get passed back to the test class via the library
}
},
{
"type": "signal", <--- signal allows you to run internal commands on the device outside of the test class
"msg":
{
"deviceId": "device1",
"cmd": "sleep", <--- puts the specified device in a wait state
"args": [
3000 <--- number of milliseconds to wait
]
}
}
]
```

-----------------------------------------------------------------------------------

## Run demo tests with the library and Google I/O scheduler sample project.

Grab the "iosched-modified" folder from the sample project on Github at
https://github.com/moquality/multidevice
and open the folder in Android Studio. Start up an instance of an emulated device (should list as "emulator-5554" when the adb devices command is run.
Compile the the project and under the Gradle tab window >install options, click the "installDebug", "installStaging", and "installStagingAndroidTest" options.
Once installed, open the I/O scheduler app to check the it is ready to run and then background the app.

In one terminal window type the following adb command:
```
> adb -s emulator-5554 shell am instrument -w -e class com.google.samples.apps.iosched.tests.pages.HomePage -e deviceId device1 com.google.samples.apps.iosched.test/androidx.test.runner.AndroidJUnitRunner
```
to spool up the I/O scheduler app in test mode referencing the HomePage test class

Now in a second terminal window, cd into the "server" folder of the sample project and type:
```
> yarn runner
```

The Google I/O app on the emulator should now run through the sample tests outlined in the HomePage class while also outputting testing status in the secon terminal window as it proceeds through each step.
4 changes: 3 additions & 1 deletion androidtest-library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ dependencies {
testImplementation 'junit:junit:4.12'

implementation 'androidx.test:runner:1.2.0'

implementation ('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down

This file was deleted.

Loading