From 2f2ff3059aa7b78e567ac9fcdaf7f6d674a932c9 Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Mon, 29 Sep 2025 16:39:33 +0530 Subject: [PATCH 1/5] add diverse sample tests --- .gitignore | 5 ++- .../run-parallel-test/moduleA/specs/test.js | 41 +++++++++++++++++++ .../run-parallel-test/moduleB/specs/test.js | 41 +++++++++++++++++++ .../run-parallel-test/parallel.conf.js | 2 +- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 android/examples/run-parallel-test/moduleA/specs/test.js create mode 100644 android/examples/run-parallel-test/moduleB/specs/test.js diff --git a/.gitignore b/.gitignore index 0f481fd..15a686e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ node_modules/ local.log errorShots -.DS_Store \ No newline at end of file +.DS_Store +*.log +performance-report*.json +package-lock.json \ No newline at end of file diff --git a/android/examples/run-parallel-test/moduleA/specs/test.js b/android/examples/run-parallel-test/moduleA/specs/test.js new file mode 100644 index 0000000..5e576a0 --- /dev/null +++ b/android/examples/run-parallel-test/moduleA/specs/test.js @@ -0,0 +1,41 @@ +const assert = require('assert'); + +describe('Test Suite', () => { + before(async () => { + var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); + await skipButton.waitForDisplayed({ timeout: 30000 }); + await skipButton.click(); + + var searchSelector = await $(`~Search Wikipedia`); + await searchSelector.waitForDisplayed({ timeout: 30000 }); + await searchSelector.click(); + + var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); + await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + await insertTextSelector.addValue("BrowserStack"); + await browser.pause(5000); + + var allProductsName = await $$(`android.widget.TextView`); + assert(allProductsName.length > 0, 'Search results should be present'); + }); + + it('Always Passing Test', () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it('Always Failing Test', () => { + assert.strictEqual(1 + 1, 3, 'This test should always fail'); + }); + + it('Flaky Test', () => { + const randomValue = Math.random(); + assert.ok(randomValue > 0.5, 'This test is flaky and may fail'); + }); + + it('Test with Retries', function () { + this.retries(2); // Framework-level retries + const randomValue = Math.random(); + assert.ok(randomValue > 0.8, 'This test retries if it fails'); + }); +}); diff --git a/android/examples/run-parallel-test/moduleB/specs/test.js b/android/examples/run-parallel-test/moduleB/specs/test.js new file mode 100644 index 0000000..3912cbd --- /dev/null +++ b/android/examples/run-parallel-test/moduleB/specs/test.js @@ -0,0 +1,41 @@ +const assert = require('assert'); + +describe('Test Suite', () => { + before(async () => { + var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); + await skipButton.waitForDisplayed({ timeout: 30000 }); + await skipButton.click(); + + var searchSelector = await $(`~Search Wikipedia`); + await searchSelector.waitForDisplayed({ timeout: 30000 }); + await searchSelector.click(); + + var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); + await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + await insertTextSelector.addValue("BrowserStack"); + await browser.pause(5000); + + var allProductsName = await $$(`android.widget.TextView`); + assert(allProductsName.length > 0, 'Search results should be present'); + }); + + it('Always Passing Test', () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it('Always Failing Test', () => { + assert.strictEqual("a" + "b", "abc", 'This test should always fail'); + }); + + it('Flaky Test', () => { + const randomValue = Math.random(); + assert.ok(randomValue > 0.5, 'This test is flaky and may fail'); + }); + + it('Test with Retries', function () { + this.retries(2); // Framework-level retries + const randomValue = Math.random(); + assert.ok(randomValue > 0.8, 'This test retries if it fails'); + }); +}); diff --git a/android/examples/run-parallel-test/parallel.conf.js b/android/examples/run-parallel-test/parallel.conf.js index 345e76b..b8a1f48 100644 --- a/android/examples/run-parallel-test/parallel.conf.js +++ b/android/examples/run-parallel-test/parallel.conf.js @@ -44,7 +44,7 @@ exports.config = { updateJob: false, specs: [ - './specs/single_test.js' + './m*/**' ], exclude: [], From c5ed758dd6789bbaf0b59c01dba0b657a674c0d8 Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Sun, 12 Oct 2025 12:52:59 +0530 Subject: [PATCH 2/5] add further changes --- .../run-parallel-test/moduleA/specs/test.js | 117 ++++++++++------ .../run-parallel-test/moduleB/specs/test.js | 126 ++++++++++++------ .../run-parallel-test/moduleC/specs/test.js | 89 +++++++++++++ 3 files changed, 254 insertions(+), 78 deletions(-) create mode 100644 android/examples/run-parallel-test/moduleC/specs/test.js diff --git a/android/examples/run-parallel-test/moduleA/specs/test.js b/android/examples/run-parallel-test/moduleA/specs/test.js index 5e576a0..4298c2e 100644 --- a/android/examples/run-parallel-test/moduleA/specs/test.js +++ b/android/examples/run-parallel-test/moduleA/specs/test.js @@ -1,41 +1,80 @@ const assert = require('assert'); -describe('Test Suite', () => { - before(async () => { - var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); - await skipButton.waitForDisplayed({ timeout: 30000 }); - await skipButton.click(); - - var searchSelector = await $(`~Search Wikipedia`); - await searchSelector.waitForDisplayed({ timeout: 30000 }); - await searchSelector.click(); - - var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); - await insertTextSelector.waitForDisplayed({ timeout: 30000 }); - - await insertTextSelector.addValue("BrowserStack"); - await browser.pause(5000); - - var allProductsName = await $$(`android.widget.TextView`); - assert(allProductsName.length > 0, 'Search results should be present'); - }); - - it('Always Passing Test', () => { - assert.strictEqual(1 + 1, 2, 'This test should always pass'); - }); - - it('Always Failing Test', () => { - assert.strictEqual(1 + 1, 3, 'This test should always fail'); - }); - - it('Flaky Test', () => { - const randomValue = Math.random(); - assert.ok(randomValue > 0.5, 'This test is flaky and may fail'); - }); - - it('Test with Retries', function () { - this.retries(2); // Framework-level retries - const randomValue = Math.random(); - assert.ok(randomValue > 0.8, 'This test retries if it fails'); - }); -}); +describe("BStackDemo Tests Module A", () => { + before(async () => { + var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); + await skipButton.waitForDisplayed({ timeout: 30000 }); + await skipButton.click(); + + var searchSelector = await $(`~Search Wikipedia`); + await searchSelector.waitForDisplayed({ timeout: 30000 }); + await searchSelector.click(); + }); + + it("module A - flaky test - random product selection", async () => { + const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; + const insertTextSelector = await $(selector); + await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + // Randomly choose a term that will always have results or never have results + const randomTerm = Math.random() > 0.5 ? "BrowserStack" : "akjsdhfakjsdhf"; // nonsense string + await insertTextSelector.addValue(randomTerm); + await browser.pause(5000); + + const allResults = await $$(`android.widget.TextView`); + // This assertion will sometimes fail if randomTerm is the nonsense string + assert(allResults.length > 0); + }); + + it("module A - always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module A - always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("module A - always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module A - always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module A - always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("module A - always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("module A - Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module A - Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module A - always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); \ No newline at end of file diff --git a/android/examples/run-parallel-test/moduleB/specs/test.js b/android/examples/run-parallel-test/moduleB/specs/test.js index 3912cbd..65d1e8d 100644 --- a/android/examples/run-parallel-test/moduleB/specs/test.js +++ b/android/examples/run-parallel-test/moduleB/specs/test.js @@ -1,41 +1,89 @@ const assert = require('assert'); -describe('Test Suite', () => { - before(async () => { - var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); - await skipButton.waitForDisplayed({ timeout: 30000 }); - await skipButton.click(); - - var searchSelector = await $(`~Search Wikipedia`); - await searchSelector.waitForDisplayed({ timeout: 30000 }); - await searchSelector.click(); - - var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); - await insertTextSelector.waitForDisplayed({ timeout: 30000 }); - - await insertTextSelector.addValue("BrowserStack"); - await browser.pause(5000); - - var allProductsName = await $$(`android.widget.TextView`); - assert(allProductsName.length > 0, 'Search results should be present'); - }); - - it('Always Passing Test', () => { - assert.strictEqual(1 + 1, 2, 'This test should always pass'); - }); - - it('Always Failing Test', () => { - assert.strictEqual("a" + "b", "abc", 'This test should always fail'); - }); - - it('Flaky Test', () => { - const randomValue = Math.random(); - assert.ok(randomValue > 0.5, 'This test is flaky and may fail'); - }); - - it('Test with Retries', function () { - this.retries(2); // Framework-level retries - const randomValue = Math.random(); - assert.ok(randomValue > 0.8, 'This test retries if it fails'); - }); -}); +describe("BStackDemo Tests Module B", () => { + before(async () => { + var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); + await skipButton.waitForDisplayed({ timeout: 30000 }); + await skipButton.click(); + + var searchSelector = await $(`~Search Wikipedia`); + await searchSelector.waitForDisplayed({ timeout: 30000 }); + await searchSelector.click(); + + // var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); + // await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + // await insertTextSelector.addValue("BrowserStack"); + // await browser.pause(5000); + + // var allProductsName = await $$(`android.widget.TextView`); + // assert(allProductsName.length > 0, 'Search results should be present'); + }); + + it("module B - flaky test - random product selection", async () => { + const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; + const insertTextSelector = await $(selector); + await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + // Randomly choose a term that will always have results or never have results + const randomTerm = Math.random() > 0.5 ? "BrowserStack" : "akjsdhfakjsdhf"; // nonsense string + await insertTextSelector.addValue(randomTerm); + await browser.pause(5000); + + const allResults = await $$(`android.widget.TextView`); + // This assertion will sometimes fail if randomTerm is the nonsense string + assert(allResults.length > 0); + }); + + it("module B - always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module B - always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("module B - always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module B - always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module B - always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("module B - always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("module B - Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module B - Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module B - always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); \ No newline at end of file diff --git a/android/examples/run-parallel-test/moduleC/specs/test.js b/android/examples/run-parallel-test/moduleC/specs/test.js new file mode 100644 index 0000000..e8997a9 --- /dev/null +++ b/android/examples/run-parallel-test/moduleC/specs/test.js @@ -0,0 +1,89 @@ +const assert = require('assert'); + +describe("BStackDemo Tests Module C", () => { + before(async () => { + var skipButton = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/fragment_onboarding_skip_button")'); + await skipButton.waitForDisplayed({ timeout: 30000 }); + await skipButton.click(); + + var searchSelector = await $(`~Search Wikipedia`); + await searchSelector.waitForDisplayed({ timeout: 30000 }); + await searchSelector.click(); + + // var insertTextSelector = await $('android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")'); + // await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + // await insertTextSelector.addValue("BrowserStack"); + // await browser.pause(5000); + + // var allProductsName = await $$(`android.widget.TextView`); + // assert(allProductsName.length > 0, 'Search results should be present'); + }); + + it("module C - flaky test - random product selection", async () => { + const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; + const insertTextSelector = await $(selector); + await insertTextSelector.waitForDisplayed({ timeout: 30000 }); + + // Randomly choose a term that will always have results or never have results + const randomTerm = Math.random() > 0.5 ? "BrowserStack" : "akjsdhfakjsdhf"; // nonsense string + await insertTextSelector.addValue(randomTerm); + await browser.pause(5000); + + const allResults = await $$(`android.widget.TextView`); + // This assertion will sometimes fail if randomTerm is the nonsense string + assert(allResults.length > 0); + }); + + it("module C - always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module C - always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("module C - always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("module C - always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module C - always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("module C - always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("module C - Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module C - Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("module C - always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); \ No newline at end of file From a36190fc3f600096ce0e457b86809216ba81998a Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Thu, 16 Oct 2025 07:18:25 +0530 Subject: [PATCH 3/5] add diverse tests --- .../run-parallel-test/moduleA/specs/test.js | 21 ++++++++++--------- .../run-parallel-test/moduleB/specs/test.js | 20 +++++++++--------- .../run-parallel-test/moduleC/specs/test.js | 20 +++++++++--------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/android/examples/run-parallel-test/moduleA/specs/test.js b/android/examples/run-parallel-test/moduleA/specs/test.js index 4298c2e..fd0be5a 100644 --- a/android/examples/run-parallel-test/moduleA/specs/test.js +++ b/android/examples/run-parallel-test/moduleA/specs/test.js @@ -11,7 +11,8 @@ describe("BStackDemo Tests Module A", () => { await searchSelector.click(); }); - it("module A - flaky test - random product selection", async () => { + it("flaky test - random product selection", async () => { + // this.tags = ['regression', 'p1']; const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; const insertTextSelector = await $(selector); await insertTextSelector.waitForDisplayed({ timeout: 30000 }); @@ -26,39 +27,39 @@ describe("BStackDemo Tests Module A", () => { assert(allResults.length > 0); }); - it("module A - always failing test - missing element 1", async () => { + it("always failing test - missing element 1", async () => { // Try to click a non-existent element, which should fail const nonExistent = await $(`~non-existent-1`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module A - always passing test - example C", async () => { + it("always passing test - example C", async () => { assert.equal(true, true); }); - it("module A - always failing test - same stacktrace 1", async () => { + it("always failing test - same stacktrace 1", async () => { // Try to click a non-existent element, which should fail (same selector as below) const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module A - always failing test - same stacktrace 2", async () => { + it("always failing test - same stacktrace 2", async () => { const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module A - always passing test - example D", async () => { + it("always passing test - example D", async () => { assert.equal(true, true); }); - it("module A - always passing test - example A", async () => { + it("always passing test - example A", async () => { assert.strictEqual(1 + 1, 2, 'This test should always pass'); }); - it("module A - Test with framework-level retry - 2 retries configured", function () { + it("Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -66,7 +67,7 @@ describe("BStackDemo Tests Module A", () => { } }); - it("module A - Another Test with framework-level retry - 2 retries configured", function () { + it("Another Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -74,7 +75,7 @@ describe("BStackDemo Tests Module A", () => { } }); - it("module A - always passing test - example B", async () => { + it("always passing test - example B", async () => { assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); }); }); \ No newline at end of file diff --git a/android/examples/run-parallel-test/moduleB/specs/test.js b/android/examples/run-parallel-test/moduleB/specs/test.js index 65d1e8d..9edd5fd 100644 --- a/android/examples/run-parallel-test/moduleB/specs/test.js +++ b/android/examples/run-parallel-test/moduleB/specs/test.js @@ -20,7 +20,7 @@ describe("BStackDemo Tests Module B", () => { // assert(allProductsName.length > 0, 'Search results should be present'); }); - it("module B - flaky test - random product selection", async () => { + it("flaky test - random product selection", async () => { const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; const insertTextSelector = await $(selector); await insertTextSelector.waitForDisplayed({ timeout: 30000 }); @@ -35,39 +35,39 @@ describe("BStackDemo Tests Module B", () => { assert(allResults.length > 0); }); - it("module B - always failing test - missing element 1", async () => { + it("always failing test - missing element 1", async () => { // Try to click a non-existent element, which should fail const nonExistent = await $(`~non-existent-1`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module B - always passing test - example C", async () => { + it("always passing test - example C", async () => { assert.equal(true, true); }); - it("module B - always failing test - same stacktrace 1", async () => { + it("always failing test - same stacktrace 1", async () => { // Try to click a non-existent element, which should fail (same selector as below) const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module B - always failing test - same stacktrace 2", async () => { + it("always failing test - same stacktrace 2", async () => { const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module B - always passing test - example D", async () => { + it("always passing test - example D", async () => { assert.equal(true, true); }); - it("module B - always passing test - example A", async () => { + it("always passing test - example A", async () => { assert.strictEqual(1 + 1, 2, 'This test should always pass'); }); - it("module B - Test with framework-level retry - 2 retries configured", function () { + it("Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -75,7 +75,7 @@ describe("BStackDemo Tests Module B", () => { } }); - it("module B - Another Test with framework-level retry - 2 retries configured", function () { + it("Another Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -83,7 +83,7 @@ describe("BStackDemo Tests Module B", () => { } }); - it("module B - always passing test - example B", async () => { + it("always passing test - example B", async () => { assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); }); }); \ No newline at end of file diff --git a/android/examples/run-parallel-test/moduleC/specs/test.js b/android/examples/run-parallel-test/moduleC/specs/test.js index e8997a9..6fbfb4d 100644 --- a/android/examples/run-parallel-test/moduleC/specs/test.js +++ b/android/examples/run-parallel-test/moduleC/specs/test.js @@ -20,7 +20,7 @@ describe("BStackDemo Tests Module C", () => { // assert(allProductsName.length > 0, 'Search results should be present'); }); - it("module C - flaky test - random product selection", async () => { + it("flaky test - random product selection", async () => { const selector = Math.random() > 0.5 ? 'android=new UiSelector().resourceId("org.wikipedia.alpha:id/search_src_text")' : 'falseSelector'; const insertTextSelector = await $(selector); await insertTextSelector.waitForDisplayed({ timeout: 30000 }); @@ -35,39 +35,39 @@ describe("BStackDemo Tests Module C", () => { assert(allResults.length > 0); }); - it("module C - always failing test - missing element 1", async () => { + it("always failing test - missing element 1", async () => { // Try to click a non-existent element, which should fail const nonExistent = await $(`~non-existent-1`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module C - always passing test - example C", async () => { + it("always passing test - example C", async () => { assert.equal(true, true); }); - it("module C - always passing test - example D", async () => { + it("always passing test - example D", async () => { assert.equal(true, true); }); - it("module C - always failing test - same stacktrace 1", async () => { + it("always failing test - same stacktrace 1", async () => { // Try to click a non-existent element, which should fail (same selector as below) const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module C - always failing test - same stacktrace 2", async () => { + it("always failing test - same stacktrace 2", async () => { const nonExistent = await $(`~common-error`); await nonExistent.waitForDisplayed({ timeout: 3000 }); await nonExistent.click(); // Will fail }); - it("module C - always passing test - example A", async () => { + it("always passing test - example A", async () => { assert.strictEqual(1 + 1, 2, 'This test should always pass'); }); - it("module C - Test with framework-level retry - 2 retries configured", function () { + it("Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -75,7 +75,7 @@ describe("BStackDemo Tests Module C", () => { } }); - it("module C - Another Test with framework-level retry - 2 retries configured", function () { + it("Another Test with framework-level retry - 2 retries configured", function () { this.retries(2); // Framework-level retry const randomOutcome = Math.random() > 0.7; if (!randomOutcome) { @@ -83,7 +83,7 @@ describe("BStackDemo Tests Module C", () => { } }); - it("module C - always passing test - example B", async () => { + it("always passing test - example B", async () => { assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); }); }); \ No newline at end of file From 5add8c151c7f8282b378614edeb53f344f7b61d1 Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Thu, 16 Oct 2025 08:56:39 +0530 Subject: [PATCH 4/5] add tests for ios --- .../run-parallel-test/moduleA/specs/test.js | 74 +++++++++++++++++++ .../run-parallel-test/moduleB/specs/test.js | 74 +++++++++++++++++++ .../run-parallel-test/moduleC/specs/test.js | 74 +++++++++++++++++++ .../run-parallel-test/parallel.conf.js | 2 +- 4 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 ios/examples/run-parallel-test/moduleA/specs/test.js create mode 100644 ios/examples/run-parallel-test/moduleB/specs/test.js create mode 100644 ios/examples/run-parallel-test/moduleC/specs/test.js diff --git a/ios/examples/run-parallel-test/moduleA/specs/test.js b/ios/examples/run-parallel-test/moduleA/specs/test.js new file mode 100644 index 0000000..ae1cae1 --- /dev/null +++ b/ios/examples/run-parallel-test/moduleA/specs/test.js @@ -0,0 +1,74 @@ +const assert = require('assert'); + +describe("BStackDemo Tests Module A", () => { + before(async () => { + var textButton = await $(`~Text Button`); + await textButton.waitForDisplayed({ timeout: 30000 }); + await textButton.click(); + + var textInput = await $(`~Text Input`); + await textInput.waitForDisplayed({ timeout: 30000 }); + await textInput.click() + await textInput.addValue("hello@browserstack.com"+"\n"); + + var textOutput = await $(`~Text Output`); + await textOutput.waitForDisplayed({ timeout: 30000 }); + var value = await textOutput.getText(); + }); + + it("flaky test - passes and fails intermittently", async () => { + assert(Math.random() > 0.3, 'Flaky test failed'); + }); + + it("always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); diff --git a/ios/examples/run-parallel-test/moduleB/specs/test.js b/ios/examples/run-parallel-test/moduleB/specs/test.js new file mode 100644 index 0000000..2c7cf0c --- /dev/null +++ b/ios/examples/run-parallel-test/moduleB/specs/test.js @@ -0,0 +1,74 @@ +const assert = require('assert'); + +describe("BStackDemo Tests Module B", () => { + before(async () => { + var textButton = await $(`~Text Button`); + await textButton.waitForDisplayed({ timeout: 30000 }); + await textButton.click(); + + var textInput = await $(`~Text Input`); + await textInput.waitForDisplayed({ timeout: 30000 }); + await textInput.click() + await textInput.addValue("hello@browserstack.com"+"\n"); + + var textOutput = await $(`~Text Output`); + await textOutput.waitForDisplayed({ timeout: 30000 }); + var value = await textOutput.getText(); + }); + + it("flaky test - passes and fails intermittently", async () => { + assert(Math.random() > 0.3, 'Flaky test failed'); + }); + + it("always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); diff --git a/ios/examples/run-parallel-test/moduleC/specs/test.js b/ios/examples/run-parallel-test/moduleC/specs/test.js new file mode 100644 index 0000000..5b0f46a --- /dev/null +++ b/ios/examples/run-parallel-test/moduleC/specs/test.js @@ -0,0 +1,74 @@ +const assert = require('assert'); + +describe("BStackDemo Tests Module C", () => { + before(async () => { + var textButton = await $(`~Text Button`); + await textButton.waitForDisplayed({ timeout: 30000 }); + await textButton.click(); + + var textInput = await $(`~Text Input`); + await textInput.waitForDisplayed({ timeout: 30000 }); + await textInput.click() + await textInput.addValue("hello@browserstack.com"+"\n"); + + var textOutput = await $(`~Text Output`); + await textOutput.waitForDisplayed({ timeout: 30000 }); + var value = await textOutput.getText(); + }); + + it("flaky test - passes and fails intermittently", async () => { + assert(Math.random() > 0.3, 'Flaky test failed'); + }); + + it("always failing test - missing element 1", async () => { + // Try to click a non-existent element, which should fail + const nonExistent = await $(`~non-existent-1`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example C", async () => { + assert.equal(true, true); + }); + + it("always passing test - example D", async () => { + assert.equal(true, true); + }); + + it("always failing test - same stacktrace 1", async () => { + // Try to click a non-existent element, which should fail (same selector as below) + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always failing test - same stacktrace 2", async () => { + const nonExistent = await $(`~common-error`); + await nonExistent.waitForDisplayed({ timeout: 3000 }); + await nonExistent.click(); // Will fail + }); + + it("always passing test - example A", async () => { + assert.strictEqual(1 + 1, 2, 'This test should always pass'); + }); + + it("Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("Another Test with framework-level retry - 2 retries configured", function () { + this.retries(2); // Framework-level retry + const randomOutcome = Math.random() > 0.7; + if (!randomOutcome) { + throw new Error("Test failed, retrying..."); + } + }); + + it("always passing test - example B", async () => { + assert.strictEqual("Browser" + "Stack", "BrowserStack", 'This test should always pass'); + }); +}); diff --git a/ios/examples/run-parallel-test/parallel.conf.js b/ios/examples/run-parallel-test/parallel.conf.js index 0dec3e2..e3a1580 100644 --- a/ios/examples/run-parallel-test/parallel.conf.js +++ b/ios/examples/run-parallel-test/parallel.conf.js @@ -42,7 +42,7 @@ exports.config = { updateJob: false, specs: [ - './specs/single_test.js' + './m*/**' ], exclude: [], From a079b5f32b72277e3b6703c87a043cc4948cb52a Mon Sep 17 00:00:00 2001 From: Rahul Singh Date: Wed, 22 Oct 2025 10:34:34 +0530 Subject: [PATCH 5/5] add build tag --- android/examples/run-parallel-test/parallel.conf.js | 4 ++++ ios/examples/run-parallel-test/parallel.conf.js | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/android/examples/run-parallel-test/parallel.conf.js b/android/examples/run-parallel-test/parallel.conf.js index b8a1f48..7941dad 100644 --- a/android/examples/run-parallel-test/parallel.conf.js +++ b/android/examples/run-parallel-test/parallel.conf.js @@ -13,6 +13,10 @@ exports.config = { browserstackLocal: true, opts: { forcelocal: false, localIdentifier: "webdriverio-appium-app-browserstack-repo" }, app: process.env.BROWSERSTACK_APP_PATH || './examples/WikipediaSample.apk', + testObservability: true, + testObservabilityOptions: { + buildTag: ['bstack_sample'], + } } ] ], diff --git a/ios/examples/run-parallel-test/parallel.conf.js b/ios/examples/run-parallel-test/parallel.conf.js index e3a1580..e5441f5 100644 --- a/ios/examples/run-parallel-test/parallel.conf.js +++ b/ios/examples/run-parallel-test/parallel.conf.js @@ -10,7 +10,11 @@ exports.config = { buildIdentifier: '${BUILD_NUMBER}', browserstackLocal: true, opts: { forcelocal: false, localIdentifier: "webdriverio-appium-app-browserstack-repo" }, - app: process.env.BROWSERSTACK_APP_PATH || './examples/BStackSampleApp.ipa' + app: process.env.BROWSERSTACK_APP_PATH || './examples/BStackSampleApp.ipa', + testObservability: true, + testObservabilityOptions: { + buildTag: ['bstack_sample'], + } } ] ],