|
6 | 6 |
|
7 | 7 | <img src="https://serenity-bdd.info/wp-content/uploads/elementor/thumbs/serenity-bdd-pac9onzlqv9ebi90cpg4zsqnp28x4trd1adftgkwbq.png" height = "100"> |
8 | 8 |
|
9 | | -## Run Sample build |
| 9 | +## Using Maven |
10 | 10 | ### Setup |
11 | 11 | * Clone the repo |
12 | 12 | * Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml. |
@@ -70,6 +70,54 @@ This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow t |
70 | 70 | ``` |
71 | 71 | * Install dependencies `mvn compile` |
72 | 72 |
|
| 73 | +## Using Gradle |
| 74 | + |
| 75 | +### Prerequisites |
| 76 | +- If using Gradle, Java v9+ is required. |
| 77 | + |
| 78 | +### Setup |
| 79 | +* Clone the repo |
| 80 | +* Replace YOUR_USERNAME and YOUR_ACCESS_KEY with your BrowserStack access credentials in browserstack.yml. |
| 81 | + |
| 82 | +### Running your tests |
| 83 | + |
| 84 | +- Clone the repository |
| 85 | +- To run the test suite having cross-platform with parallelization, run `gradle sampleTest` |
| 86 | +- To run local tests, run `gradle sampleLocalTest` |
| 87 | + |
| 88 | +Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github) |
| 89 | + |
| 90 | +### Integrate your test suite |
| 91 | + |
| 92 | +This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack: |
| 93 | + |
| 94 | +* Following are the changes required in `build.gradle` - |
| 95 | + * Add `id 'com.browserstack.gradle-sdk' version "1.1.2"` in plugins |
| 96 | + * Add `implementation 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies |
| 97 | + * Fetch Artifact Information and add `jvmArgs` property in tasks *SampleTest* and *SampleLocalTest* : |
| 98 | + ``` |
| 99 | + def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' } |
| 100 | + |
| 101 | + task sampleTest(type: Test) { |
| 102 | + dependsOn cleanTest |
| 103 | + include '**/SampleTest.**' |
| 104 | + jvmArgs "-javaagent:${browserstackSDKArtifact.file}" |
| 105 | + useJUnitPlatform() |
| 106 | + } |
| 107 | + ``` |
| 108 | +* Following are the changes required in `settings.gradle` - |
| 109 | + * Add `resolutionStrategy` inside `pluginManagement` |
| 110 | + * Inside `resolutionStrategy` add the plugin `id` as `com.browserstack.gradle-sdk` along with module `version` |
| 111 | + ``` |
| 112 | + eachPlugin { |
| 113 | + if (requested.id.id == "com.browserstack.gradle-sdk") { |
| 114 | + useModule("com.browserstack:gradle-sdk:1.1.2") |
| 115 | + } |
| 116 | + } |
| 117 | + ``` |
| 118 | + |
| 119 | +* Install dependencies and run test `gradle sampleTest` |
| 120 | + |
73 | 121 | ## Notes |
74 | 122 | * You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate) |
75 | 123 | * You can export the environment variables for the Username and Access Key of your BrowserStack account |
|
0 commit comments