-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Android] Enable usage of custom instrumentation test runners #675
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe("AndroidDriver", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drivers are not unit tested on purpose. The mostly touch command line tools and are just wrappers. Unit tests don't give much value. They are being tested in the e2e suite. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is doing some regex voodoo so that's why I thought about adding one at least, but I'm ok with removing it. |
||
let mockClient; | ||
let driver; | ||
let ADB; | ||
|
||
beforeEach(() => { | ||
jest.mock("npmlog"); | ||
|
||
jest.mock("./android/ADB"); | ||
ADB = require("./android/ADB"); | ||
|
||
const AndroidDriver = require("./AndroidDriver"); | ||
|
||
driver = new AndroidDriver(jest.fn()); | ||
}); | ||
|
||
it("getInstrumentationRunner", async () => { | ||
const adbShellPmListInstrumentationOutput = | ||
"instrumentation:com.android.emulator.smoketests/android.support.test.runner.AndroidJUnitRunner (target=com.android.emulator.smoketests)\n" + | ||
"instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)\n" + | ||
"instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)\n" + | ||
"instrumentation:org.chromium.webview_shell/.WebViewLayoutTestRunner (target=org.chromium.webview_shell)\n"; | ||
|
||
const adbMockInstance = ADB.mock.instances[0]; | ||
adbMockInstance.listInstrumentation.mockReturnValue( | ||
Promise.resolve(adbShellPmListInstrumentationOutput) | ||
); | ||
|
||
const result = await driver.getInstrumentationRunner( | ||
"deviceId", | ||
"com.example.android.apis" | ||
); | ||
expect(result).toEqual( | ||
"com.example.android.apis/.app.LocalSampleInstrumentation" | ||
); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,10 @@ xdescribe('ADB', () => { | |
await adb.unlockScreen('deviceId'); | ||
expect(exec).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should consider dropping unit tests on ADB as well, but for now, don't delete this test |
||
it('listInstrumentation', async () => { | ||
await adb.listInstrumentation('deviceId'); | ||
expect(exec).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
; missing