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

Misc refactor #30

Merged
merged 18 commits into from
Aug 25, 2018
Merged

Misc refactor #30

merged 18 commits into from
Aug 25, 2018

Conversation

ultrasecreth
Copy link
Member

No description provided.

@@ -179,7 +187,8 @@ private[mockito] trait MockitoEnhancer extends MockCreator {
/**
* Delegates to <code>Mockito.withSettings()</code>, it's only here to expose the full Mockito API
*/
def withSettings: MockSettings = Mockito.withSettings()
def withSettings(implicit defaultAnswer: Answer[_]): MockSettings =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe default this so it can be used without the implicit in scope? also update the doc

@@ -11,45 +12,93 @@ import org.mockito.session.MockitoSessionLogger
import scala.collection.mutable
import scala.collection.JavaConverters._

class MockitoScalaSession(name: String, strictness: Strictness, logger: MockitoSessionLogger) {
private val listener = new IgnoreDefaultArgumentsMockListener
class MockitoScalaSession private (name: String, strictness: Strictness, logger: MockitoSessionLogger) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this so people can integrate this using before/after hooks

Copy link
Contributor

@Krever Krever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👍

README.md Outdated
```
That's it! that block of code will execute within a session and will handle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will handle what?

@@ -39,34 +41,42 @@ trait IdiomaticMockito extends MockCreator {
when(stubbing) thenAnswer functionToAnswer(f)

def shouldAnswer[P0, P1, P2](f: (P0, P1, P2) => T): OngoingStubbing[T] =
when(stubbing) thenAnswer functionToAnswer(f)
when(stubbing) thenAnswer functionToAnswer(
f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny formatting I have to say. Is it scalafmt or sth else causing this?

else
throw new SmartNullPointerException(
s"""You have a NullPointerException because this method call was *not* stubbed correctly:
|[$unStubbedInvocation] on the Mock [${unStubbedInvocation.getMock}]""".stripMargin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

classOf[Iterator[_]] -> Iterator.empty,
classOf[Stream[_]] -> Stream.empty,
classOf[Vector[_]] -> Vector.empty,
classOf[Try[_]] -> Failure(new MockitoException("Auto stub provided by mockito-scala")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe Future as well?

I would also think about making it a bit more extensible, so one could add monix or cats-io or other types here as well. OTOH I don't expect people to actually do that as this is something you find very useful when its already there but you don't hit it often enough to put the effort into extending this functionality.

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

Successfully merging this pull request may close these issues.

None yet

2 participants