### Get Project using Go Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Retrieve project details using Go's standard net/http package. This example demonstrates making a GET request and reading the response body. Replace `` with your API token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects/projectId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Project using Ruby Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Fetch project details using Ruby's Net::HTTP library. This example shows how to set headers and make a GET request. Replace `` with your API token. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/projects/projectId") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Project using Swift Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Fetch project details using Swift's URLSession. This example shows how to configure the request, set headers, and handle the response. Replace `` with your API token. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://tester.army/api/v1/projects/projectId")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### List Test Runs (Ruby) Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/list-test-runs.md A Ruby example using Net::HTTP to fetch test runs. It demonstrates setting up the HTTP client, creating a GET request, and adding the necessary authorization header. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/runs") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Install and Authenticate TesterArmy CLI Source: https://docs.tester.army/cli/agentic-usage.md Install the TesterArmy CLI globally and authenticate your session. This is a one-time setup for agentic use. ```bash npm install -g testerarmy ta auth ta status --json ``` -------------------------------- ### Get Project using JavaScript (Fetch API) Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Fetch project details using the browser's Fetch API. This example uses async/await for cleaner asynchronous code. Replace `` with your API token. ```javascript const url = 'https://tester.army/api/v1/projects/projectId'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### CI Usage: YAML Configuration Example Source: https://docs.tester.army/cli/local-dev.md An example of how to configure a CI pipeline step to run Tester Army tests, setting necessary environment variables for API key and target URL. ```yaml - name: Run QA tests run: npx testerarmy tests run --group --project --parallel 3 --json env: TESTERARMY_API_KEY: ${{ secrets.TESTERARMY_API_KEY }} TESTERARMY_TARGET_URL: ${{ steps.deploy.outputs.url }} ``` -------------------------------- ### List Projects using PHP Guzzle Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-projects.md This PHP example uses the Guzzle HTTP client to fetch a list of projects. Make sure you have Guzzle installed via Composer and replace `` with your API bearer token. ```php request('GET', 'https://tester.army/api/v1/projects', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` -------------------------------- ### List Test Runs (JavaScript) Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/list-test-runs.md Fetch test runs using the fetch API in JavaScript. This example demonstrates making a GET request and handling the JSON response. Includes basic error handling. ```javascript const url = 'https://tester.army/api/v1/runs'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Project using Python SDK Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Use the Python requests library to fetch project details. Ensure you have the library installed and replace `` with your actual API token. ```python import requests url = "https://tester.army/api/v1/projects/projectId" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Project using C# (RestSharp) Source: https://docs.tester.army/api-reference/tester-army-api/projects/get-a-project.md Use the RestSharp library in C# to make the API request. This example demonstrates setting the method and authorization header. Replace `` with your API token. ```csharp using RestSharp; var client = new RestClient("https://tester.army/api/v1/projects/projectId"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Update Project using Ruby SDK Source: https://docs.tester.army/api-reference/tester-army-api/projects/update-a-project.md This Ruby example shows how to update a project. Replace '' with your API token. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/projects/projectId") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Install and Authenticate TesterArmy CLI Source: https://docs.tester.army/get-started/quick-start.md Install the TesterArmy CLI globally and authenticate it using your API key. The CLI stores the key locally for future use. ```bash npm install -g testerarmy testerarmy auth ``` -------------------------------- ### List Test Groups using C# RestSharp Source: https://docs.tester.army/api-reference/tester-army-api/groups/list-test-groups.md A C# example using the RestSharp library to make a GET request for listing test groups. Ensure you have the RestSharp NuGet package installed. ```csharp using RestSharp; var client = new RestClient("https://tester.army/api/v1/groups?projectId=projectId"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Create Project using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project.md This Go program shows how to create a project by making an HTTP POST request. It includes setting headers and the request body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects" payload := strings.NewReader("{\n \"name\": \"string\",\n \"url\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Test Run Status using Java Unirest Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/get-test-run-status.md Demonstrates fetching test run status with the Unirest library in Java. This example sets the Authorization header for the GET request. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://tester.army/api/v1/runs/id") .header("Authorization", "Bearer ") .asString(); ``` -------------------------------- ### Initiate Mobile App Upload with Ruby Source: https://docs.tester.army/api-reference/tester-army-api/projects/initiate-a-project-mobile-app-upload.md This Ruby example demonstrates initiating a mobile app upload using Net::HTTP. It covers setting up the URI, request headers, and sending the POST request. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/projects/projectId/mobile/upload") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"filename\": \"string\",\n \"fileSize\": 1\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### List Project Files using Swift URLSession Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-files.md This Swift example shows how to fetch project files using URLSession. Ensure you replace '' with your API authentication token. ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://tester.army/api/v1/projects/projectId/files")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get a Test using C# RestSharp Source: https://docs.tester.army/api-reference/tester-army-api/tests/get-a-test.md This C# example uses the RestSharp library to fetch test details. Ensure you replace '' with your API bearer token. ```csharp using RestSharp; var client = new RestClient("https://tester.army/api/v1/tests/testId"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### List Project Files using JavaScript Fetch API Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-files.md This JavaScript example demonstrates how to fetch a list of project files using the Fetch API. Replace '' with your API authentication token. ```javascript const url = 'https://tester.army/api/v1/projects/projectId/files'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Test Groups using PHP GuzzleHttp Source: https://docs.tester.army/api-reference/tester-army-api/groups/list-test-groups.md This PHP example uses the GuzzleHttp client to fetch test groups. Make sure to install the GuzzleHttp library via Composer. ```php request('GET', 'https://tester.army/api/v1/groups?projectId=projectId', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Create Project Credential using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project-credential.md Use the Go net/http package to send a POST request to create a project credential. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects/projectId/credentials" payload := strings.NewReader("{ \n \"kind\": \"login\",\n \"label\": \"string\",\n \"username\": \"string\",\n \"password\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve a Test Group using Python SDK Source: https://docs.tester.army/api-reference/tester-army-api/groups/get-a-test-group.md Use this Python snippet to make a GET request to the API to fetch a test group by its ID. Ensure you have the 'requests' library installed. ```python import requests url = "https://tester.army/api/v1/groups/groupId" headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Test Run Status using PHP Guzzle Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/get-test-run-status.md This PHP example uses the Guzzle HTTP client to retrieve test run status. It configures the request with the required Authorization header. ```php request('GET', 'https://tester.army/api/v1/runs/id', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Agent Prompt for Project Setup Source: https://docs.tester.army/get-started/quick-start.md Use this prompt to instruct your coding agent to set up QA for a project using the TesterArmy CLI. It includes creating a project, generating and running a test, and reporting results. ```txt Use the TesterArmy CLI (`testerarmy`) to set up QA for this project. Create a project, generate a test, run it, and report the run ID and results. Use `testerarmy --help` and prefer JSON output. ``` -------------------------------- ### Initiate Mobile App Upload (API) Source: https://docs.tester.army/mobile/app-uploads.md Use this endpoint to start a three-step presigned upload for large mobile artifacts. It returns an upload URL and storage key. ```bash POST /v1/projects/{projectId}/mobile/upload with { filename, fileSize } ``` -------------------------------- ### Get a Test using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/tests/get-a-test.md This Go code demonstrates how to fetch test data using the standard net/http package. Replace '' with your API key for authentication. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/tests/testId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Typical Local Development Workflow Source: https://docs.tester.army/cli/local-dev.md A common sequence of commands for local development, including starting the dev server, setting the target URL, making changes, running tests, and checking results. ```bash # 1) Start dev server pnpm dev # 2) Set target export TESTERARMY_TARGET_URL="http://localhost:3000" # 3) Make changes # 4) Run targeted test ta tests run # 5) Check results, iterate ta runs list --project ``` -------------------------------- ### Create Project Memory using Ruby Net::HTTP Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project-memory.md A Ruby example using the Net::HTTP library to send a POST request for creating a project memory. Remember to replace the placeholder token. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/projects/projectId/memories") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"category\": \"site_structure\",\n \"title\": \"string\",\n \"content\": \"string\",\n \"importance\": \"high\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### List Projects using C# RestSharp Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-projects.md This C# code uses the RestSharp library to make a GET request to the Tester Army API for listing projects. Ensure you have the RestSharp NuGet package installed. ```csharp using RestSharp; var client = new RestClient("https://tester.army/api/v1/projects"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Create Project Memory using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project-memory.md This Go code demonstrates how to make an HTTP POST request to create a project memory. It includes reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects/projectId/memories" payload := strings.NewReader("{\n \"category\": \"site_structure\",\n \"title\": \"string\",\n \"content\": \"string\",\n \"importance\": \"high\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Update Project using PHP SDK (Guzzle) Source: https://docs.tester.army/api-reference/tester-army-api/projects/update-a-project.md This PHP example uses the Guzzle HTTP client to update a project. Make sure you have Guzzle installed via Composer and replace '' with your API token. ```php request('PATCH', 'https://tester.army/api/v1/projects/projectId', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Test Run Status using JavaScript Fetch API Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/get-test-run-status.md Employ the `fetch` API in JavaScript to asynchronously retrieve test run status. This example includes basic error handling for the network request. ```javascript const url = 'https://tester.army/api/v1/runs/id'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Project Files using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-files.md This Go program shows how to retrieve project files via the Tester Army API using the default HTTP client. Remember to substitute '' with your valid API token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects/projectId/files" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Create Test using Swift URLSession Source: https://docs.tester.army/api-reference/tester-army-api/tests/create-a-test.md This Swift example demonstrates creating a test using URLSession. It shows how to set up the HTTP headers, request body, and handle the response. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "title": "string", "steps": [ [ "title": "string", "type": "act" ] ], "projectId": "string" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://tester.army/api/v1/tests")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Run TesterArmy CLI without Installation Source: https://docs.tester.army/cli.md Execute TesterArmy CLI commands without a global installation using npx. This is useful for quick checks or when global installation is not desired. ```bash npx testerarmy --help ``` -------------------------------- ### List Test Groups using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/groups/list-test-groups.md Example of listing test groups with Go's standard net/http package. Remember to replace placeholders with actual values. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/groups?projectId=projectId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Webhook URL Example Source: https://docs.tester.army/guides/testing-staging.md This is an example of the webhook URL format used to trigger tests. ```text https://tester.army/api/v1/groups/webhook/{id}/{secret} ``` -------------------------------- ### List Projects using JavaScript Fetch API Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-projects.md This JavaScript example demonstrates how to fetch a list of projects using the `fetch` API. It includes error handling for network issues. Replace `` with your API bearer token. ```javascript const url = 'https://tester.army/api/v1/projects'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Update Project Request Example Source: https://docs.tester.army/api-reference/tester-army-api/projects/update-a-project.md This is an example of an empty request body for updating a project. ```json {} ``` -------------------------------- ### Get Test Run Status using C# RestSharp Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/get-test-run-status.md Shows how to get test run status using the RestSharp library in C#. The code sets up a GET request and adds the Authorization header. ```csharp using RestSharp; var client = new RestClient("https://tester.army/api/v1/runs/id"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### List Project Memories (Go) Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-memories.md This Go code snippet demonstrates how to fetch project memories using the standard net/http package. Remember to substitute `projectId` and ``. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/projects/projectId/memories" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Trigger Test Run Response Example Source: https://docs.tester.army/api-reference/tester-army-api/tests/trigger-a-test-run.md This is an example of the JSON response received after triggering a test run. ```json { "status": "queued", "runId": "string", "testId": "string" } ``` -------------------------------- ### List Test Groups Response Example Source: https://docs.tester.army/api-reference/tester-army-api/groups/list-test-groups.md Example JSON structure for a successful response when listing test groups. ```json { "groups": [ { "id": "string", "name": "string", "isDefault": true, "testCount": 1, "prepTestId": "string" } ] } ``` -------------------------------- ### List Tests using Go HTTP Client Source: https://docs.tester.army/api-reference/tester-army-api/tests/list-tests.md This Go program demonstrates how to fetch tests from the Tester Army API using the standard net/http package. Remember to replace `` with your valid API token. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://tester.army/api/v1/tests?projectId=projectId" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Install and Authenticate TesterArmy CLI Source: https://docs.tester.army/guides/migrate-from-cypress.md Install the TesterArmy CLI globally and authenticate your agent. For non-interactive sessions, set the TESTERARMY_API_KEY environment variable. ```bash npm install -g testerarmy ta auth ``` -------------------------------- ### Create Project using Swift URLSession Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project.md This Swift code demonstrates creating a project using URLSession. It sets up the POST request with headers and the JSON body. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "name": "string", "url": "string" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://tester.army/api/v1/projects")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Install TesterArmy CLI Source: https://docs.tester.army/cli.md Install the TesterArmy CLI globally using npm. This command makes the `testerarmy` and `ta` commands available on your system. ```bash npm install -g testerarmy ``` -------------------------------- ### Create Project using PHP GuzzleHttp Source: https://docs.tester.army/api-reference/tester-army-api/projects/create-a-project.md This PHP example uses the GuzzleHttp client to create a project. It configures the POST request with headers and the JSON body. ```php request('POST', 'https://tester.army/api/v1/projects', [ 'body' => '{\n "name": "string",\n "url": "string"\n}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### List Project Memories (Ruby) Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-memories.md A Ruby example using Net::HTTP to access project memories. Ensure you replace `projectId` and `` with your specific values. ```ruby require 'uri' require 'net/http' url = URI("https://tester.army/api/v1/projects/projectId/memories") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Upload Raw .app Directory with CLI Source: https://docs.tester.army/mobile/app-uploads.md Upload a raw `.app` directory to TesterArmy. `--app-path` and `--project` are required parameters. ```bash testerarmy upload-app \ --app-path ios/build/Build/Products/Release-iphonesimulator/MyApp.app \ --project ``` -------------------------------- ### Mabl Test Inventory Export Example Source: https://docs.tester.army/guides/migrate-from-mabl.md Example of how to structure a Mabl test inventory in a markdown file. This format helps in mapping Mabl test steps to TesterArmy steps. ```md # Plan: Checkout regression (staging, https://staging.shop.example.com) ## Test: Guest checkout - Visit home page - Search for "running shoes" - Open the first product - Add to cart - Check out as guest with a valid US address - Assert: order confirmation page shows an order number ## Flow used by multiple tests: Login - Visit /login - Sign in as standard user ``` -------------------------------- ### List Project Memories (JavaScript) Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-memories.md Utilize the fetch API to retrieve project memories. This example includes basic error handling. Replace `projectId` and `` accordingly. ```javascript const url = 'https://tester.army/api/v1/projects/projectId/memories'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get a Test using Java Unirest Source: https://docs.tester.army/api-reference/tester-army-api/tests/get-a-test.md This Java snippet uses the Unirest library to make a GET request for test data. Remember to replace '' with your API key. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://tester.army/api/v1/tests/testId") .header("Authorization", "Bearer ") .asString(); ``` -------------------------------- ### Get a Test using JavaScript Fetch API Source: https://docs.tester.army/api-reference/tester-army-api/tests/get-a-test.md Utilize the JavaScript fetch API to get test information. Remember to substitute '' with your valid API authentication token. ```javascript const url = 'https://tester.army/api/v1/tests/testId'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Project Files using PHP Guzzle Source: https://docs.tester.army/api-reference/tester-army-api/projects/list-project-files.md This PHP example uses the Guzzle HTTP client to retrieve project files. Remember to replace '' with your API bearer token. ```php request('GET', 'https://tester.army/api/v1/projects/projectId/files', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Get Test Run Status API Endpoint Source: https://docs.tester.army/api-reference/tester-army-api/test-runs/get-test-run-status.md Use this GET request to retrieve the current status and result of a test run. Poll this endpoint periodically to check for completion. ```http GET https://tester.army/api/v1/runs/{id} ```