I jammed a message class as follows (within a TestNG unit test class):
< Pre> @ set to safe mode first () {message = mock (message square); }
I can assure you that I have declared the message
type message
in the unit test class. Now, there is a frequency variable called category
in the message
category that is a type of string type:
public class messages {private string category ; Public string getCategory () {return category; } Public Zero Set Category (string category) {this.category = category; }}
OK, now the problem: within a short test method, I have to set the category
a duplicate message
and Then use that category
for any other work in unit testing. However, when I set the category
to mocked
message, this code changes again on null
this code is:
Public should be zero Category with category () {message.setCategory ("F1 racing"); // Set Category Category Race Resalt. Add Subscriber ("F1 Racing", Client A); System.out.println ("Cat" + message.getCategory ()); // The classification of message is tap race. Result (message); Verify (customer's) .receive (message); }
console null
- so I know this definitely null
. I was trying to understand it for two days, but it seems that I am missing something so any help would be appreciated.
instead you mock ()
. Then you can put the set value. You can use another option, doReturn ("F1 Racing"). When (message) .getcategory ();
to return the value you want to return.
Comments
Post a Comment