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(vscode): Improved Unit Test Generation UI & C# Class Structure #6506

Open
wants to merge 9 commits into
base: developer/UnitTestCodeful
Choose a base branch
from

Conversation

samikay101
Copy link
Contributor

@samikay101 samikay101 commented Jan 29, 2025

Work Item Links:


Type of Change

  • Bug fix
  • Feature
  • Other

Current Behavior

  • The "Create Unit Test" option is available in the run menu on the Overview blade, but this feature is now being removed.
  • No telemetry exists for the "Create Unit Test" from scratch option in the VS Code extension, making it difficult to track usage.
  • The "Create Unit Test" buttons in the VS Code extension do not indicate their preview status, potentially misleading users about the feature's maturity.
  • C# class generation for unit tests does not have a well-structured folder hierarchy, leading to redundant and inconsistent file generation.

New Behavior

1. Frontend: Remove Create Unit Test from Run Option in Overview Blade

  • The "Create Unit Test" option has been removed from the run dropdown in the Overview blade.
  • No functional impact; users will still be able to create unit tests via other designated entry points.

2. [VS Code Extension] Add Telemetry for Create from Scratch

  • Added telemetry tracking for when users create a unit test from scratch in the VS Code extension.
  • Helps gather insights on usage patterns and user adoption.

3. Add "(Preview)" to Create Unit Test Buttons

  • The "Create Unit Test" buttons in the VS Code extension now display (Preview), signaling that the feature is in an experimental phase.
  • This ensures users have clear expectations and provides an opportunity for feedback before general availability.

4. Improve C# Class Folder Generation, Naming, and Workflow Synchronization

Restructuring C# Class Folder Hierarchy

  • Generated C# classes are now placed in dedicated subfolders under each workflow.
  • A new MockOutputs folder stores common C# classes shared across multiple unit tests.
  • Improves organization, maintainability, and discoverability of generated files.

Preventing Duplicate C# Classes for the Same Operation

  • Updated class generation logic to avoid redundant class creation for the same API operation.
  • Example: If multiple actions in a workflow use ReadAResourceGroup, all instances will now reference a single class (ReadAResourceGroupMockOutput.cs) instead of creating unnecessary duplicates (ReadAResourceGroup1.cs, ReadAResourceGroup2.cs, etc.).
  • This optimization reduces clutter and ensures consistency across unit test files.

Standardizing Naming for Generated C# Classes

  • Updated naming conventions to append "MockOutput" to generated C# classes.
  • Example: ReadAResourceGroup.csReadAResourceGroupMockOutput.cs
  • Example: WhenAHTTPRequestIsReceived.csWhenAHTTPRequestIsReceivedMockOutput.cs
  • Improves clarity by explicitly marking these classes as mock output representations.

Expected Outcome

  • A cleaner and more structured file hierarchy for generated unit test classes.
  • Fewer duplicate classes, reducing unnecessary files and improving maintainability.
  • More intuitive and standardized naming conventions.
  • Better workflow synchronization, ensuring unit tests stay up to date with workflow changes.

Impact of Change

  • This is a breaking change.
    No breaking changes expected. The changes improve functionality, telemetry tracking, and organization.

Test Plan

[Frontend] Remove Create Unit Test from Run Option in Overview Blade

  • Testing Plan: N/A – see screenshot below.

[VS Code Extension] Add Telemetry for Create from Scratch

  • Unit tests added in apps/vs-code-designer/src/app/utils/codeful/saveBlankUnitTest.test.ts.

[VS Code Extension] Add "(Preview)" to Create Unit Test Buttons

  • Testing Plan: N/A – see screenshot below.

[Improve C# Class Folder Generation, Naming, and Workflow Synchronization]

  • Unit tests added in apps/vs-code-designer/src/app/utils/codeful/saveBlankUnitTest.test.ts.
  • Verified that:
    • C# classes are generated under the correct workflow-specific subfolders.
    • Mock output classes are stored in the MockOutputs folder.
    • Duplicate classes for the same API operation are no longer created.
    • New naming conventions (MockOutput suffix) are correctly applied.

Screenshots or Videos (if applicable)

Before and After Screenshots: Remove Create Unit Test from Run Option in Overview Blade

Before:
image

After:
image


Before and After Screenshots: Add "(Preview)" to Create Unit Test Buttons

Before:
image
image

After:
image
image


Additional Notes

  • These changes improve usability, structure, and performance in the unit test workflow.
  • The updated C# class organization ensures a more maintainable codebase.
  • The preview label on unit test buttons sets clear expectations for users, reducing confusion.
  • Telemetry tracking will provide valuable insights into feature adoption.

…ction output, add preview flag to create unit test from run and create blank unit test, remove option to create unit test from overview blade
@samikay101 samikay101 requested a review from hartra344 as a code owner January 29, 2025 21:32
* @param error - The error to parse.
* @returns {string} - A user-friendly error string.
*/
export function parseErrorBeforeTelemetry(error: any): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests for this function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file needed? or is it a mock for some unit tests?

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