rsocket-java
rsocket-java copied to clipboard
Add ability to mock an RSocket connection for better isolation & testability
Add ability to mock an RSocket connection within unit tests to isolate functionality to one end of an RSocket connection for testing.
Motivation
Without the ability to mock an RSocket connection in unit tests, unit tests effectively become integration tests. The (current) necessity to create both RSocket client and server within a unit test adds a large amount of indirectly-related code that falls outside of the scope of testing one end of the connection and its functionality.
Desired solution
Provide a mechanism to mock an RSocket connection.
Considered alternatives
Current solution is to create and configure both ends, RSocket client and server, prior to testing an RSocket client. This adds a considerable amount of code to even a simple test and reduces the clarity and concision of the test.
Additional context
N/A
See https://github.com/spring-cloud/spring-cloud-contract/issues/1173
If we're just talking about simple mocking it out then that's not enough. It would be great to have an option to teach this mock how to behave, store the mock definition in a file that can be shared. That means that the stubbed RSocket server should have an API to reach it and tell it how to behave. Having a http://wiremock.org but for RSocket would be fantastic.
+1