Skip to content

Commit

Permalink
Document the tvos_unit_test and tvos_ui_test rules.
Browse files Browse the repository at this point in the history
RELNOTES: Document the tvos_unit_test and tvos_ui_test rules.
PiperOrigin-RevId: 257453996
  • Loading branch information
Googler authored and swiple-rules-gardener committed Jul 10, 2019
1 parent fb0e2b2 commit 1e0972c
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ extensions, and frameworks) and for running unit tests and UI tests.
<code><a href="rules-tvos.md#tvos_extension">tvos_extension</a></code><br/>
</td>
<td valign="top">
Coming soon.
<code><a href="rules-tvos.md#tvos_ui_test">tvos_ui_test</a></code><br/>
<code><a href="rules-tvos.md#tvos_unit_test">tvos_unit_test</a></code><br/>
</td>
</tr>
<tr>
Expand Down
253 changes: 253 additions & 0 deletions doc/rules-tvos.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,256 @@ and extensions, list it in the `frameworks` attributes of those
</tr>
</tbody>
</table>

## tvos_ui_test

```python
tvos_ui_test(name, bundle_id, infoplists, minimum_os_version, runner,
test_host, data, deps, provisioning_profile, [test specific attributes])
```

Builds and bundles a tvOS UI `.xctest` test bundle. Runs the tests using the
provided test runner when invoked with `bazel test`.

The following is a list of the `tvos_ui_test` specific attributes; for a list of
the attributes inherited by all test rules, please check the
[Bazel documentation](https://bazel.build/versions/master/docs/be/common-definitions.html#common-attributes-tests).

<table class="table table-condensed table-bordered table-params">
<colgroup>
<col class="col-param" />
<col class="param-description" />
</colgroup>
<thead>
<tr>
<th colspan="2">Attributes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#name">Name</a>, required</code></p>
<p>A unique name for the target.</p>
</td>
</tr>
<tr>
<td><code>bundle_id</code></td>
<td>
<p><code>String; optional</code></p>
<p>The bundle ID (reverse-DNS path) of the test bundle. It cannot be the
same bundle ID as the <code>test_host</code> bundle ID. If not
specified, the <code>test_host</code>'s bundle ID will be used with a
"Tests" suffix.</p>
</td>
</tr>
<tr>
<td><code>infoplists</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>A list of <code>.plist</code> files that will be merged to form the
<code>Info.plist</code> that represents the test bundle. If not
specified, a default one will be provided that only contains the
<code>CFBundleName</code> and <code>CFBundleIdentifier</code> keys with
placeholders that will be replaced when bundling. Please see
<a href="common_info.md#infoplist-handling">Info.plist Handling</a>
for what is supported.</p>
</td>
</tr>
<tr>
<td><code>minimum_os_version</code></td>
<td>
<p><code>String; optional</code></p>
<p>An optional string indicating the minimum tvOS version supported by the
target, represented as a dotted version number (for example,
<code>"9.0"</code>). If this attribute is omitted, then the value specified
by the flag <code>--tvos_minimum_os</code> will be used instead.
</td>
</tr>
<tr>
<td><code>runner</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#labels">Label</a>; optional</code></p>
<p>A target that will specify how the tests are to be run. This target
needs to be defined using a rule that provides the
<code>AppleTestRunnerInfo</code> provider.</p>
</td>
</tr>
<tr>
<td><code>test_host</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#labels">Label</a>; required</code></p>
<p>A <code>tvos_application</code> target that represents the app that
will be tested using XCUITests. This is required as passing a default
has no meaning in UI tests.
</p>
</td>
</tr>
<tr>
<td><code>data</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>The list of files needed by this rule at runtime.</p>
<p>Targets named in the data attribute will appear in the `*.runfiles`
area of this rule, if it has one. This may include data files needed by
a binary or library, or other programs needed by it.</p>
</td>
</tr>
<tr>
<td><code>deps</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>A list of dependencies targets to link into the binary. Any
resources, such as asset catalogs, that are referenced by those targets
will also be transitively included in the final test bundle.</p>
</td>
</tr>
<tr>
<td><code>provisioning_profile</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#labels">Label</a>; optional</code></p>
<p>The provisioning profile (<code>.mobileprovision</code> file) to use
when bundling the test bundle. This value is optional for simulator
builds as the simulator doesn't fully enforce entitlements, but is
<strong>required for device builds.</strong></p>
</td>
</tr>
<tr>
<td><code>[test specific attributes]</code></td>
<td>
<p>For a list of the attributes inherited by all test rules, please check the
<a href="https://bazel.build/versions/master/docs/be/common-definitions.html#common-attributes-tests">Bazel documentation</a>.
</p>
</td>
</tr>
</tbody>
</table>

## tvos_unit_test

```python
tvos_unit_test(name, bundle_id, infoplists, minimum_os_version, runner,
test_host, data, deps, [test specific attributes])
```

Builds and bundles a tvOS Unit `.xctest` test bundle. Runs the tests using the
provided test runner when invoked with `bazel test`.

`tvos_unit_test` targets can work in two modes: as app or library tests. If the
`test_host` attribute is set to an `tvos_application` target, the tests will run
within that application's context. If no `test_host` is provided, the tests will
run outside the context of a tvOS application. Because of this, certain
functionalities might not be present (e.g. UI layout, NSUserDefaults). You can
find more information about app and library testing for Apple platforms
[here](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/03-testing_basics.html).

The following is a list of the `tvos_unit_test` specific attributes; for a list
of the attributes inherited by all test rules, please check the
[Bazel documentation](https://bazel.build/versions/master/docs/be/common-definitions.html#common-attributes-tests).

<table class="table table-condensed table-bordered table-params">
<colgroup>
<col class="col-param" />
<col class="param-description" />
</colgroup>
<thead>
<tr>
<th colspan="2">Attributes</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#name">Name</a>, required</code></p>
<p>A unique name for the target.</p>
</td>
</tr>
<tr>
<td><code>bundle_id</code></td>
<td>
<p><code>String; optional</code></p>
<p>The bundle ID (reverse-DNS path) of the test bundle. It cannot be the
same bundle ID as the <code>test_host</code> bundle ID. If not
specified, the <code>test_host</code>'s bundle ID will be used with a
"Tests" suffix.</p>
</td>
</tr>
<tr>
<td><code>env</code></td>
<td>
<p><code>Dictionary of strings; optional</code></p>
<p>Dictionary of environment variables that should be set during the
test execution.</p>
</td>
</tr>
<tr>
<td><code>infoplists</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>A list of <code>.plist</code> files that will be merged to form the
<code>Info.plist</code> that represents the test bundle. If not
specified, a default one will be provided that only contains the
<code>CFBundleName</code> and <code>CFBundleIdentifier</code> keys with
placeholders that will be replaced when bundling. Please see
<a href="common_info.md#infoplist-handling">Info.plist Handling</a>
for what is supported.</p>
</td>
</tr>
<tr>
<td><code>minimum_os_version</code></td>
<td>
<p><code>String; optional</code></p>
<p>An optional string indicating the minimum tvOS version supported by the
target, represented as a dotted version number (for example,
<code>"9.0"</code>). If this attribute is omitted, then the value specified
by the flag <code>--tvos_minimum_os</code> will be used instead.
</td>
</tr>
<tr>
<td><code>runner</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#labels">Label</a>; optional</code></p>
<p>A target that will specify how the tests are to be run. This target
needs to be defined using a rule that provides the <code>AppleTestRunnerInfo</code>
provider.</p>
</td>
</tr>
<tr>
<td><code>test_host</code></td>
<td>
<p><code><a href="https://bazel.build/versions/master/docs/build-ref.html#labels">Label</a>; optional</code></p>
<p>A <code>tvos_application</code> target that represents the app that
will host the tests. If not specified, the runner will assume it's a
library-based test.</p>
</td>
</tr>
<tr>
<td><code>data</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>The list of files needed by this rule at runtime.</p>
<p>Targets named in the data attribute will appear in the `*.runfiles`
area of this rule, if it has one. This may include data files needed by
a binary or library, or other programs needed by it.</p>
</td>
</tr>
<tr>
<td><code>deps</code></td>
<td>
<p><code>List of <a href="https://bazel.build/versions/master/docs/build-ref.html#labels">labels</a>; optional</code></p>
<p>A list of dependencies targets to link into the binary. Any
resources, such as asset catalogs, that are referenced by those targets
will also be transitively included in the final test bundle.</p>
</td>
</tr>
<tr>
<td><code>[test specific attributes]</code></td>
<td>
<p>For a list of the attributes inherited by all test rules, please check the
<a href="https://bazel.build/versions/master/docs/be/common-definitions.html#common-attributes-tests">Bazel documentation</a>.
</p>
</td>
</tr>
</tbody>
</table>

0 comments on commit 1e0972c

Please sign in to comment.