> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qa.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# fastlane pull request testing

> Review a mobile pull request build from a fastlane lane by calling the change review API.

Use this when a [fastlane](https://github.com/fastlane/fastlane) lane builds the iOS or Android binary for a pull request and you want a change review of that binary. To run a test plan against the build, use [fastlane regression testing](https://docs.qa.tech/regression-testing/fastlane.md).

## Set it up

> [card] [Add the lane](#add-the-lane)
>
> Upload the pull request build, then start a change review pinned to it.

> [card] [Post the review](#post-the-review)
>
> Connect GitHub or GitLab so the agent can read the diff and post comments.

> [card] [Get the results](https://docs.qa.tech/pr-testing/api.md#get-the-results)
>
> Poll the conversation the same way as any other API-started review.

Store `QATECH_API_TOKEN`, `QATECH_APP_ID`, and, for org-scoped keys, `QATECH_PROJECT_ID` as described on [fastlane regression testing](https://docs.qa.tech/regression-testing/fastlane.md#set-it-up). You do not need a test plan for a change review.

## What works with fastlane

| Capability | fastlane |
| :- | :- |
| Review on a preview URL, before merge | No. fastlane builds native apps; use your web CI guide for preview URLs. |
| Review a mobile build for that pull request | Yes, if the lane uploads the build and calls the change review API. fastlane does not post the review on its own. |
| Run a regression test plan | Not from this guide. See [fastlane regression testing](https://docs.qa.tech/regression-testing/fastlane.md). |
| Block the lane until the review finishes | No documented blocking check for a change review. Blocking is documented for test plan runs. |

## Add the lane

Copy `qatech_request` and `qatech_upload_build` from [fastlane regression testing](https://docs.qa.tech/regression-testing/fastlane.md#add-the-lane) into `fastlane/Fastfile`, then add:

```ruby fastlane/Fastfile theme={null}
# Starts a change review of the pull request, pinned to the uploaded build.
def qatech_change_review(build_short_id:, pr_url:, vcs_provider_id: "github")
  review = qatech_request(:post, "/chat/change-review", {
    mode: "pr",
    prUrl: pr_url,
    vcsProviderId: vcs_provider_id,
    applicationOverrides: [{
      applicationShortId: ENV.fetch("QATECH_APP_ID"),
      environment: { applicationBuildShortId: build_short_id }
    }]
  })
  UI.success("Started QA.tech change review: #{review['url']}")
  review["shortId"]
end

platform :android do
  lane :qatech_review do |options|
    gradle(task: "assemble", build_type: "Debug")
    build_id = qatech_upload_build(
      file: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
      platform: "android"
    )
    qatech_change_review(build_short_id: build_id, pr_url: options.fetch(:pr_url))
  end
end
```

For iOS, build and zip the simulator `.app` as in the [regression lane](https://docs.qa.tech/regression-testing/fastlane.md#add-the-lane), upload it with `platform: "ios"`, then call `qatech_change_review`.

Pass the pull request URL from your CI. On GitHub Actions:

```bash theme={null}
bundle exec fastlane android qatech_review pr_url:"https://github.com/$GITHUB_REPOSITORY/pull/$PR_NUMBER"
```

Set `PR_NUMBER` from `github.event.pull_request.number`. For a GitLab merge request, pass the merge request URL and `vcs_provider_id: "gitlab"`.

## Post the review

fastlane does not post the review by itself. Before the lane calls the change review API:

1. Connect the [GitHub App](https://docs.qa.tech/configuration/github-app.md) with access to the repository, **or** connect [GitLab MR reviews](https://docs.qa.tech/pr-testing/gitlab.md#set-up-gitlab-mr-reviews).
2. Pass a `pr_url` the agent can resolve (GitHub PR or GitLab MR).
3. The agent reads the diff and posts the review through that connection.

Without that connection, the conversation may start but nothing is posted on the request. Turn off GitHub App **Auto-run on PRs** when the lane owns the review, or a second review runs against the default environment instead of the PR build. Polling and dashboard links are the same as [API pull request testing](https://docs.qa.tech/pr-testing/api.md#get-the-results).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.