mainCalculateAnnualReturn()

org.opentest4j.AssertionFailedError: expected: <0.814> but was: <0.3347747199150335>

Go to the test folder, you’ll find a file named PortfolioManagerApplicationTest there.

In it look for a method called mainCalculateAnnualReturn().

Try to use VSC debugger to debug the method, or you could try to pass the arguments passed in the function while running your file and compare the arguments.

Hey @shad0w this means logic you have implemented to calculate Annualizedreturns is not correct so you have to take care of that so make sure your logic is correct and as @adityab said debug it you will be able to find out where are you making mistake.

Try converting duration to days and then calculate using number of days.
And prefer using chronounit for day calculation.

Did you go through this thread?

1 Like

if logic is incorrect then how result is correct for these two test testCalculateAnnualizedReturn()
testCalculateAnnualizedReturnGoogl() @amanagar

yes i am doing this
Double noOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate) * 1.0;
Double time = noOfDaysBetween / 365.00;

Hey @shad0w that’s why i have told you debug it.

can u plz elaborate what u trying to explain??

you should not forget there are edge cases also so be aware about them

Don’t you know what is debugging?

can u plz explain about edge cases @amanagar

thanks everyone, final solve it. sorting order :joy: