Assessment fails at unit testing for these testcases

Failed testcases:

calculateAnnualizedReturnNoDataOnEndDate()

calculateExtrapolatedAnnualizedReturn()

I ran build test and got this.

Task :qmoney:test

com.crio.warmup.stock.portfolio.PortfolioManagerTest > calculateExtrapolatedAnnualizedReturn() FAILED
org.mockito.exceptions.misusing.UnnecessaryStubbingException

TEST RESULT: FAILURE
TEST SUMMARY: RAN 14 TESTS, 13 SUCCEEDED, 1 FAILED, 0 SKIPPED

14 tests completed, 1 failed

Task :qmoney:test FAILED

Looked at all FAQs related to this but couldn’t figure out the problem.
Do look into my code.
@Rahul-Crio.do @amanagar @sashi_Crio.Do

Hey, we have a potential FAQ on this :slight_smile:
https://forum.crio.do/t/error-unnecessarystubbingexception-during-tests/7796/2
Refer the above link

1 Like

Looked at all FAQs related to this but couldn’t figure out the problem. I am using getStockQuote in getAnnualizedReturn instead of directly using it in calculateAnnualizedReturn, is that a problem?

That’s what the FAQ says :slight_smile:

Will look into that. In Module 3, I used getAnnualizedReturn in combination with calculateAnnualizedReturn to make it simpler and for the sake of clean code. So, now I need to put everything under calculateAnnualizedReturn? Wouldn’t that reduce my code quality?

That’s what Milestone task 1 is right ?
you can copy your logic from 3-> 4 , you can have getAnnualizedReturns but make sure you are calling the getStockQuote inside calculateannualized returns.
You called the TiingoCandle class in CalculateAnnualized returns right, here you are using getStockQuote to divide and separate the functionality.
Hope I was clear :slight_smile:

1 Like

Yep, makes sense. Thanks! Will work on that.

Just reply back when your testcase pases :slight_smile:

Hey, my build is successful but during assessment now I only get

calculateAnnualizedReturnNoDataOnEndDate()

testcase as failed. Do check my logic for the endDate.

Hey you can refer to this FAQ for that :slight_smile:

Hey, since its been more than 12 hours, and I have not received any response from you , I am closing this ticket