blob: 03c3f7f79bcd0f081a3cab1fb5b8e2882c320a0e [file] [log] [blame] [view]
Daniel Erat10513362017-09-26 18:25:531# Tast Quickstart
2
3[TOC]
4
5## Prerequisites
6
Daniel Eratfe123692018-09-05 20:17:357You'll need a [Chrome OS chroot]. If you've only done Chrome development so far,
8note that this is different from the Chrome checkout described in the [Simple
9Chrome] documentation.
Daniel Erat10513362017-09-26 18:25:5310
11You'll also need a Chrome OS device running a system image built with the `test`
12flag that's reachable from your workstation via SSH. An image running in a
Daniel Eratfe123692018-09-05 20:17:3513[virtual machine] will also work. If you're using a test image that you
14downloaded rather than one built in your chroot, make sure that it's a recent
15version.
Daniel Erat10513362017-09-26 18:25:5316
Daniel Erat69966c12017-09-29 23:39:1717## Run a prebuilt test
Daniel Erat10513362017-09-26 18:25:5318
19In your chroot, run the following:
20
21```sh
Kevin Shelton4deb1892018-05-18 19:40:4122tast -verbose run -build=false <test-device-ip> ui.ChromeLogin
Daniel Erat10513362017-09-26 18:25:5323```
24
25You should see output scroll by on your workstation, and on the Chrome OS
26device, the test should log in and load a webpage. After the test is done, take
27a look at the results in `/tmp/tast/results/latest` in your chroot.
28
Daniel Erat69966c12017-09-29 23:39:1729## Build and run a test
30
31The previous step ran a test that was already built into your device's system
32image, but you can also use the `tast` command to quickly rebuild all tests and
33push them to the device.
34
35In your chroot, run the same command as before **but without the `-build=false`
36argument**:
37
38```sh
Kevin Shelton4deb1892018-05-18 19:40:4139tast -verbose run <test-device-ip> ui.ChromeLogin
Daniel Erat69966c12017-09-29 23:39:1740```
41
42This time, the command will take a bit longer (but build objects will be
43cached). The test should succeed again.
44
45> The first time you run this, or after you sync your checkout, you may see an
46> error similar to the following:
47```
48To install missing dependencies, run:
49
50 sudo emerge -j 16 \
51   =dev-go/cdp-0.9.1-r1 \
52   =dev-go/dbus-0.0.2-r5
53```
54> This is expected: to speed things up, `tast` is building the tests directly
Daniel Eratd7773002017-12-30 11:11:3455> instead of emerging the `tast-local-tests-cros` package, so it needs some help
56> from you to make sure that all required dependencies are installed. If you run
57> the provided `emerge` command, the `tast` command should work when re-run.
Daniel Erat69966c12017-09-29 23:39:1758
Daniel Erat10513362017-09-26 18:25:5359See [Running Tests] for more information.
60
61## Modify a test
62
Daniel Erat69966c12017-09-29 23:39:1763Now, let's modify the test. In your Chrome OS checkout, go to
Daniel Eratd7773002017-12-30 11:11:3464`src/platform/tast-tests/src/chromiumos/tast/local/bundles/cros/ui` and open
Kevin Sheltonb922f1e2018-05-18 20:17:5665`chrome_login.go` (for convenience, there's also a `local_tests` symlink at the
Kevin Shelton4deb1892018-05-18 19:40:4166top of `tast-tests`). The `ChromeLogin` function here will run directly on the
Daniel Erat10513362017-09-26 18:25:5367test device.
68
69At the end of the function, add the following code:
70
71```go
72if _, err = cr.NewConn(s.Context(), "https://www.google.com/"); err != nil {
73 s.Error("Failed to open page: ", err)
74}
75```
76
Daniel Erat69966c12017-09-29 23:39:1777Back in your chroot, run `tast` again:
Daniel Erat10513362017-09-26 18:25:5378
79```sh
Kevin Shelton4deb1892018-05-18 19:40:4180tast -verbose run <test-device-ip> ui.ChromeLogin
Daniel Erat10513362017-09-26 18:25:5381```
82
Daniel Erat69966c12017-09-29 23:39:1783This time, the test should additionally open a Google search page.
Daniel Erat10513362017-09-26 18:25:5384
85Return to the test file and add the following statement at the end of the
86function:
87
88```go
89s.Error("This is an intentional error")
90```
91
92If you build and run the test again, you should see it fail.
93
Daniel Eratfe123692018-09-05 20:17:3594See [Writing Tests] for more information, and explore the [tast-tests
95repository] to see existing tests and related packages.
96
97## Next steps
98
99Additional Tast documentation is available in the [tast repository].
Daniel Erat10513362017-09-26 18:25:53100
101Many resources are available for learning more about Go. Here are a few:
102
103* [A Tour of Go] - In-browser introduction to Go's core features.
104* [Official Go documentation] - Package documentation, specifications, blog
105 posts, and recorded talks.
106* [Community Learn wiki] - Links to external resources.
107
Daniel Erat10513362017-09-26 18:25:53108[Chrome OS chroot]: http://www.chromium.org/chromium-os/quick-start-guide
Daniel Eratfe123692018-09-05 20:17:35109[Simple Chrome]: https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md
110[virtual machine]: https://chromium.googlesource.com/chromiumos/docs/+/master/cros_vm.md
Daniel Erat10513362017-09-26 18:25:53111[Running Tests]: running_tests.md
112[Writing Tests]: writing_tests.md
Daniel Eratfe123692018-09-05 20:17:35113[tast-tests repository]: https://chromium.googlesource.com/chromiumos/platform/tast-tests/
114[tast repository]: https://chromium.googlesource.com/chromiumos/platform/tast/
Daniel Erat10513362017-09-26 18:25:53115[A Tour of Go]: https://tour.golang.org/
116[Official Go documentation]: https://golang.org/doc/
117[Community Learn wiki]: https://github.com/golang/go/wiki/Learn