blob: ad10bc1eb0117fb526a4835e39c70957b44ac505 [file] [log] [blame] [view]
Daniel Erat10513362017-09-26 18:25:531# Tast Quickstart
2
3[TOC]
4
5## Prerequisites
6
7You'll need a [Chrome OS chroot].
8
9You'll also need a Chrome OS device running a system image built with the `test`
10flag that's reachable from your workstation via SSH. An image running in a
11[virtual machine] will also work.
12
13## Run a test
14
15In your chroot, run the following:
16
17```sh
18tast -verbose run -build=false <test-device-ip> ui.ChromeSanity
19```
20
21You should see output scroll by on your workstation, and on the Chrome OS
22device, the test should log in and load a webpage. After the test is done, take
23a look at the results in `/tmp/tast/results/latest` in your chroot.
24
25See [Running Tests] for more information.
26
27## Modify a test
28
29In your Chrome OS checkout, go to
30`src/platform/tast-tests/src/chromiumos/tast/local/tests/ui` and open
31`chrome_sanity.go`. The `ChromeSanity` function here will run directly on the
32test device.
33
34At the end of the function, add the following code:
35
36```go
37if _, err = cr.NewConn(s.Context(), "https://www.google.com/"); err != nil {
38 s.Error("Failed to open page: ", err)
39}
40```
41
42Back in your chroot, run the following:
43
44```sh
45tast -verbose run <test-device-ip> ui.ChromeSanity
46```
47
48(Note how `-build=false` is omitted; as a result, the `tast` command will
49rebuild tests locally and push them to the device. You may be prompted to
50install some dependencies needed to build tests; if so, run the provided
51`emerge` command and then re-run the `tast` command.)
52
53This time, the updated test should additionally open a Google search page.
54
55Return to the test file and add the following statement at the end of the
56function:
57
58```go
59s.Error("This is an intentional error")
60```
61
62If you build and run the test again, you should see it fail.
63
64See [Writing Tests] for more information.
65
66Many resources are available for learning more about Go. Here are a few:
67
68* [A Tour of Go] - In-browser introduction to Go's core features.
69* [Official Go documentation] - Package documentation, specifications, blog
70 posts, and recorded talks.
71* [Community Learn wiki] - Links to external resources.
72
73[virtual machine]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/running-chromeos-image-under-virtual-machines
74[Chrome OS chroot]: http://www.chromium.org/chromium-os/quick-start-guide
75[Running Tests]: running_tests.md
76[Writing Tests]: writing_tests.md
77[A Tour of Go]: https://tour.golang.org/
78[Official Go documentation]: https://golang.org/doc/
79[Community Learn wiki]: https://github.com/golang/go/wiki/Learn