Test and Docs: Hand in Hand
Shauvik Roy Choudhary, PhD
Founder, MoQuality
https://moquality.com
Documentation: Developer v End-user
Developing Apps is Hard …
Photo credits: blog.fullstory.com
Your
App
Expectations / Background
Device Capability
Languages / Symbols
Other apps installed
Network conditions
Usage patterns
Distant from servers
User is King
I need a ONE CHANCE
I need a
ONE CHANCE
How do we create docs today?
Online Help
In-App Help
Source: helpstack.io
Source: Google Maps App
In-App Chat
Source: intercom.io
Source: smooch.io
Walkthroughs / Hints
Video promos
So, what’s the problem?
App
Version 1
App
Version 2
Tests have the same problem
Regression Testing
App
Version 1
Tests
Version 1
?
App
Version 2
PASS
FAIL
CHANGE
IN THE APP
OR
Idea:
Test Reports could become Docs
Test Structure (JUnit 4)
@Before�public void runBeforeEveryTest() {/*Setup*/}
@Test�public void actualTest() {� result = doAction();� assertTrue(result);�}
@After�public void runAfterEveryTest() {/*Teardown*/}
Example Test Actions: Espresso
onView(Matcher)
.perform(ViewAction)
.check(ViewAssertion)
Example Test Actions: Espresso
onView(withId(R.id.greeting))
.perform(click());
onView(withText("Hello Steve!"))
.check(matches(isDisplayed()));
Example Test Actions: Appium
driver.findElement(By.id(“Greeting”))� .click();
driver.findElement(By.id(“Text Field”))� .sendKeys(“Hello World!”);
Detour: Test Capture (Recording)
Android Studio Test Recorder
generates Espresso Tests
Barista App for recording tests
generates
Espresso, Appium & UIAutomator Tests
http://moquality.com/barista
Ok, i’m sold.
How can Tests generate Docs ?
BDD: Readable Tests and Test Reports
Feature: Adding item to Todo list
Scenario: Add item in Empty todo list
Given The Todo list is empty
When The user clicks “Add Task” button
And The user enters “item A” in “EditText”
And The user presses “ADD” button
Then Todo list contains “item A”
Feature: Adding item to Todo list
Scenario: Add item in Empty todo list
Given The Todo list is empty
When The user clicks “Add Task” button
And The user enters “item A” in “EditText”
And The user presses “ADD” button
Then Todo list contains “item A”
Generating better Test Reports
Goals:
DocTest Tool
Tests
DocTest
Android
Emulator
Or Device
Appium
Test Reports
Docs
https://github.com/moquality/doctest
Thanks!
Parting thoughts:
Does your app have End-user Docs?
Would you reuse Test Reports as Docs?