How to pass Calculate Returns Varying Date Ranges and Calculate Returns Old Trades

Tests Failed :

  • ModuleThreeTest.mainCalculateReturnsOldTrades()

  • ModuleThreeTest.mainCalculateReturnsVaryingDateRanges()

Background :
Iterated over all possible heuristics but failed.
Followed all similar forum posts but not succeeded.
#Many - Build Failure!
Now it is exhausting :sweat:

Any guide in the right direction is appreciated as our guider unitTest.log is blank out.

Hey @imbipulkumar, module 3 is just about calculating annual returns. Thus there are many cases possible when you call API for getting values. So, if you open test file for mod 3 there you can visualize which test case handle which type of Data and dates. In your cases you’re getting error in returns old trade.
Which actually means your test cases are failing when 2 past dates are supplied to the function as parameter (start and end both). Similarly you can see for returns varying date ranges. And use debugger when you’re check test cases it will be easier for you to detect failure points.

My ModuleThreeTest.java file is empty .Can you help me out as I am getting the same two errors??

hey these test cases are hidden just make sure that you are calculating years correctly.

Hey @Shreyavv12, see can you able to locate test files? If yes then please go to the functions named

  1. CalculateReturnsOldTrades()
  2. main.CalculateReturnsVaryingDateRange()

Read each function definition and try to understand why your test case is failing under those conditions?

Debug these calling function using debugger. Put break points at significant lines (mostly before return state).

If you’re able to do that reply to this message otherwise will give you more hints.

@Shreyavv12, mine too is empty and I checked the original content from where we pulled the data - it’s empty too

The tests are defined in a different file

try to check the sorting part, if you using the correct formula.it will definitely fix the issue.

In which file are the tests defined?? Did you get it?

My debug output of returnOldTrade is successful but the assessment is failing.
Also there is no function CalculateReturnsVaryingDateRange() in moduleTwoTest or PortfolioManagerApplicationTest
How do I check where my code is failing?

Are using sorting (ascending)? See what return old trade check is data between two old dates suppose startDate = 2018-02-01 & endDate = 2019-02-01. Just put break point before returning value where you’re sorting thing. And goto that chemistry flask like icon on left run test from there (as per module 1). You’ll see variables window on left side of the window. Check your function returning output. And there will be definitely CalculateReturnsVaryingDateRange() if your test case is failing. And what this function do is it will call function which you implemented on different dates!

If you’re failing any test cases in any module please use debugger in VScode.

Yes sorting is correct, in module 2 my assessment passed, why is it failing now?

Under the beaker icon tests ,module two and PortfolioManagerApplication tests are showing.Module 3 tests are not showing.How are we supposed to debug ?

They are hidden cases. You need to debug by thinking where your logic fails, the corner cases.

The file ModuleThreeTest.java is empty ,I am not able to locate these functions.

similar issue solved in this thread,

Hey stuck at the same place. Did you solve it?

Calculate number of day and then divide by 365 to calculate number of total years.

Hey @Jitender mainCalculateReturnsOldTrades() is still failing

Establish a check for start date and organization start date if test case be like
Start date 1988 and you are trying to retrieve data before 1988 that is not possible so solve the edge cases