Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: render test failure counter #1215

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Nov 12, 2024

What does this PR do?

Updates Running Tests stage to

  • render a completed/failed test counter
  • render test failures on each data update for CI output

before

Screenshot 2024-11-12 at 4 09 16 PM

after

Screen.Recording.2024-12-12.at.6.41.36.PM.mov

Testing notes:

setup:

  1. checkout this PR
  2. link this PR of oclif/mso into the plugin branch: feat: add alwaysPrintInCI option oclif/multi-stage-output#76

(you can skip step 2 to see how it misses test failures)

using my scratch org, deploy any component and run tests in the org (already deployed tests that will fail there), example on dreamhouse project:

CI=true sf project deploy start --metadata ApexClass:FileUtilities --test-level RunSpecifiedTests --tests GeocodingServiceTest --tests TestPropertyController

You should get 3 test failures, all printed on each poll update.

What issues does this PR fix or reference?

@W-17203886@
forcedotcom/cli#3104

@cristiand391 cristiand391 marked this pull request as ready for review December 12, 2024 22:02
@mdonnalley
Copy link
Collaborator

QA:

🟢 failure count shown in HRO

❯ sf project deploy start --metadata ApexClass:FileUtilities --test-level RunSpecifiedTests --tests GeocodingServiceTest --tests TestPropertyController
 ›   Warning: @salesforce/plugin-agent is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will
 ›   be used instead.

 ─────────────── Deploying Metadata ───────────────

 Deploying v61.0 metadata to [email protected] using the v63.0 REST API.

 ✔ Preparing 177ms
 ◯ Waiting for the org to respond - Skipped
 ✔ Deploying Metadata 999ms
   ▸ Components: 1/1 (100%)
 ✘ Running Tests 2.18s
   ▸ Successful: 3/6 (50%)
   ▸ Failed: 3/6 (50%)
 ◼ Updating Source Tracking
 ◼ Done

 Status: Failed
 Deploy ID: 0AfAE000004iKrx0AE
 Target Org: [email protected]
 Elapsed Time: 3.44s


Test Failures [3]
• GeocodingServiceTest.successResponse
  message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
  stacktrace:
    Class.GeocodingServiceTest.successResponse: line 32, column 1

• TestPropertyController.testGetPagedPropertyList
  message: System.AssertException: Assertion Failed: Expected: 4, Actual: 5
  stacktrace:
    Class.TestPropertyController.testGetPagedPropertyList: line 70, column 1

• TestPropertyController.testGetPicturesWithResults
  message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
  stacktrace:
    Class.TestPropertyController.testGetPicturesWithResults: line 118, column 1


Test Results Summary
Passing: 3
Failing: 3
Total: 6
Time: 2316
 ›   Warning: FileUtilities - Test coverage of selected Apex Class is 0%, at least 75% test coverage is required

🟢 failure count and failures are shown in CI

❯ CI=true sf project deploy start --metadata ApexClass:FileUtilities --test-level RunSpecifiedTests --tests GeocodingServiceTest --tests TestPropertyController
 ›   Warning: @salesforce/plugin-agent is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will
 ›   be used instead.
───── Deploying Metadata ─────
Stages:
1. Preparing
2. Waiting for the org to respond
3. Deploying Metadata
4. Running Tests
5. Updating Source Tracking
6. Done

▶ Preparing…
   Deploying v61.0 metadata to [email protected] using the v63.0 REST API.
   Deploy ID: 0AfAE000004iKtZ0AU
   Target Org: [email protected]
✔ Preparing (213ms)
▶ Waiting for the org to respond…
✔ Waiting for the org to respond (1.75s)
▶ Deploying Metadata…
   Components: 0/1 (0%)
   Components: 1/1 (100%)
✔ Deploying Metadata (807ms)
▶ Running Tests…
   Successful: 2/6 (33%)
   Failed: 1/6 (17%)
   • GeocodingServiceTest.successResponse
     message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
     stacktrace:
       Class.GeocodingServiceTest.successResponse: line 32, column 1

   Successful: 3/6 (50%)
   Failed: 2/6 (33%)
   • TestPropertyController.testGetPagedPropertyList
     message: System.AssertException: Assertion Failed: Expected: 4, Actual: 5
     stacktrace:
       Class.TestPropertyController.testGetPagedPropertyList: line 70, column 1

   Failed: 3/6 (50%)
   • TestPropertyController.testGetPicturesWithResults
     message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
     stacktrace:
       Class.TestPropertyController.testGetPicturesWithResults: line 118, column 1

✘ Running Tests (1.43s)

Deploying v61.0 metadata to [email protected] using the v63.0 REST API.
Status: Failed
Deploy ID: 0AfAE000004iKtZ0AU
Target Org: [email protected]

Elapsed time: 4.21s

Test Results Summary
Passing: 3
Failing: 3
Total: 6
Time: 1379
 ›   Warning: FileUtilities - Test coverage of selected Apex Class is 0%, at least 75% test coverage is required

🔴 stage-specific updates are not gated

❯ CI=true sf project deploy start --source-dir force-app --test-level RunLocalTests
 ›   Warning: @salesforce/plugin-agent is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used
 ›   instead.
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will
 ›   be used instead.
───── Deploying Metadata ─────
Stages:
1. Preparing
2. Waiting for the org to respond
3. Deploying Metadata
4. Running Tests
5. Updating Source Tracking
6. Done

▶ Preparing…
   Deploying v61.0 metadata to [email protected] using the v63.0 REST API.
   Deploy ID: 0AfAE000004iKyP0AU
   Target Org: [email protected]
✔ Preparing (159ms)
◯ Waiting for the org to respond - Skipped
▶ Deploying Metadata…
   Components: 6/93 (6%)
   Components: 24/93 (26%)
   Components: 64/93 (69%)
   Components: 74/93 (80%)
   Components: 75/93 (81%)
   Components: 77/93 (83%)
   Components: 86/93 (92%)
   Components: 90/93 (97%)
   Components: 93/93 (100%)
✔ Deploying Metadata (15.31s)
▶ Running Tests…
   Successful: 2/11 (18%)
   Successful: 3/11 (27%)
   Successful: 6/11 (55%)
   Failed: 1/11 (9%)
   • GeocodingServiceTest.successResponse
     message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
     stacktrace:
       Class.GeocodingServiceTest.successResponse: line 32, column 1

   Successful: 7/11 (64%)
   Failed: 2/11 (18%)
   • TestPropertyController.testGetPagedPropertyList
     message: System.AssertException: Assertion Failed: Expected: 4, Actual: 5
     stacktrace:
       Class.TestPropertyController.testGetPagedPropertyList: line 70, column 1

   Failed: 3/11 (27%)
   • TestPropertyController.testGetPicturesWithResults
     message: System.AssertException: Assertion Failed: Expected: 3, Actual: 1
     stacktrace:
       Class.TestPropertyController.testGetPicturesWithResults: line 118, column 1

   Successful: 8/11 (73%)
✘ Running Tests (4.02s)

Deploying v61.0 metadata to [email protected] using the v63.0 REST API.
Status: Failed
Deploy ID: 0AfAE000004iKyP0AU
Target Org: [email protected]

Elapsed time: 19.49s

Test Results Summary
Passing: 8
Failing: 3
Total: 11
Time: 3697

see oclif/multi-stage-output#76 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants