Skip to content

[test]: Unit Tests for PortfolioInfo Methods #5

@0PrashantYadav0

Description

@0PrashantYadav0

Description

  • Detailed Description:
    The utility methods in PortfolioInfo have no tests, leaving potential edge cases (such as an empty list or null values) unchecked. Unit tests are crucial to ensure the methods work as intended.
  • How to Solve:
    1. Create a Test Class:
      Create a new JUnit test class (e.g., PortfolioInfoTest) in the test folder.
    2. Write Test Cases:
      Write tests for each method. For instance:
      @Test
      public void testCalculateTotalPortfolioValue_emptyList() {
          List<Stock> stocks = new ArrayList<>();
          double value = PortfolioInfo.calculateTotalPortfolioValue(stocks);
          assertEquals(0.0, value, 0.01);
      }
    3. Test Various Scenarios:
      Include tests for normal data, edge cases, and possible erroneous inputs.
    4. Run the Tests:
      Execute the test suite and ensure all tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions