Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(kotlin related) with.is with default value instead of null #98

Open
mgenov opened this issue Sep 30, 2017 · 2 comments
Open

(kotlin related) with.is with default value instead of null #98

mgenov opened this issue Sep 30, 2017 · 2 comments
Assignees

Comments

@mgenov
Copy link

mgenov commented Sep 30, 2017

Kotlin has semantic for nullable types which causes issues with using of with.is as it always returns null value and forces requirement for the param to be defined as nullable type.

Given the following method definition:

fun getTasks(employee: Employee): Tasks

When expection is set for the parameter:

oneOf(tasks).getTasks(with.`is`(anything<Employee>()))

Then test fails with:

java.lang.IllegalStateException: with.`is`(anything<Employee>()) must not be null
@racingDeveloper
Copy link

It looks like the problem is the return null in:
public <T> T with(Matcher<T> matcher) { addParameterMatcher(matcher); return null; }

What about returning a new Object?

@mgenov
Copy link
Author

mgenov commented Apr 21, 2018

The result should be the generic type and It should throw typecast I suppose as you will have to return something like (T)Any().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants