Sign in Go Pro


String Matchers - anyString()

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



#Description: This lesson describes what a Matcher is, and how you can use the provided anyString() matcher to return stubs for methods which accept String parameters. When you stub a method which takes a String parameter, you can configure your stubs to only match on specific Strings, or you can configure your stub to match on any String; this lesson will show you how to achieve both of these options. Additionally, if you pass null instead of a String to the stubbed method and want your stubbed answer to be returned, you will need to use a different matcher, as discussed in the lesson. #Summary of Content: - What a Matcher is - How to return a stub value for specific string inputs - How to return a stub value for any string inputs - How to return a stub value for null inputs - How to cast the any() matcher if using Java 7 #Code Links: - #Other Relevant Links: - -



Lessons in Mockito