Thursday, 15 August 2013

java - Mock a private method of the class under test in JMockit -


In my class exam (CUT) - an ejac - I have a personal method "getConnection" I cut any other I want to test the method, but this method will fail before hand.

I showed it below, but the "invoke" is wrong. I do not want to call this method, I want to stub it. but how? ('Connection' is a stub)

  New Non-Strike Expectation () {{Avoc (Archived Bean, "Matching Connection"); Result = connection; }}; ArchivingBean.moveCreditBasic2Archive (New Date ());    

Your test is correct, except that it opens an announcement for . EJB class, in this case.

Generally, jokes are fun in complete (all methods). In such cases, you will declare a @Mocked MyEJB archivingBean parameter in the test method, for example.

For fun partial , on the other hand, you use the NonStrictExpectations (Object ...) constructor, such as:

  New Non-Strike Expectations (Collections Bean) {{// //    

No comments:

Post a Comment