java - jMock "unexpected invocation" for a method that I have a oneOf(instance).method() expected -


I can not seem to know what I'm doing wrong:

This method I tested I am:

  Public list & lt; Mo & gt; Filter Duplicate sub-listing (list & lt; MO & gt; dbMos) {list & lt; String & gt; Name = lists.newearlest (); (Mo mo: DBMS) {try {string name = mo.getName ()} if (Numbers of names (name)) {dbMos.remove (mo); } And {names.add (name); }} Catch (pre-data expansion) {dbMos.remove (mo); }} Return dbMos; }   

And this is my test class:

  package com.rondavu.wt.service.recommendations; Import com.google.common.collect.Lists; Import com.rondavu.data.api.Mo; Import org.jmock.expectations; Import org.jmock.Mockery; Import org.jmock.lib.legacy.ClassImposteriser; Import org.junit.Before; Import org.junit.Test; Import java.util.ArrayList; Import java.util.list; Import static org.junit.assert.assertEquals; Public Class Recommendations alttsstest {funny reference = new wizzy (); RecommendationsCreate Recommendations = New Recommendations (Tools); Last mo mo = reference Mock (M. category); @Test Public Zero Test Filter Duplicates ByName_oneMo () DataLayer Uption {List & lt; Mo & gt; Input = lists.newerelists (mo); & Lt; Mo & gt; Expected = lists Environmentalist (Mo); Context.checking (new requirements) {{anoff (mo) .getName (); (Return value ("MO1"));}}); & Lt; Mo & gt; Actual = recommendations utilities.filter duplicate subsystem (input); Context.assertIsSatisfied (); Emphasis (expected, real); }}   

When I run the trial, I get this output:

  Unexpected invite: mo.getName () No expectations are specified: Did you ... - Forget to start expecting a cardinality clause? - Call a cool method to specify the expected parameter? What happened before: Nothing! [Stack Trace]   

I am very new to Jmoc, and Java is not my strongest language in general, but I thought my oneoff (mo) .getName ( ) Hope that inventions I am doing wrong here?

While it is not clear at this point, this joke is like defining your expectations Try to insert a context.mock (Mo.class) in the same local area as a test case (or an @requirer method), to test a different example of Mo compared to that and see Does he fix things or not?

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -