-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add interface for Temporal
class 🔧
#10
Add interface for Temporal
class 🔧
#10
Conversation
Why is it a problem to set return types to the builder classes? |
@cappuc in the future, you might return interfaces instead of concrete classes, like it was done in the original Temporal SDK (for example |
Changing the return type from object to an interface is a breaking change anyway, so I prefer to set the return type explicit. |
In this case, unit testing in isolation won't be possible, since concretes are returned, and you'll need to implement your fake using these concretes. I think I can create an interface for each class and change these return types to make it unit-testable, but you'll need to ship it with a warning for others that the new release contains BC. Would you want to go this way? |
Can you post an example? I can't understand why you need to mock the builder classes. |
@cappuc what you're describing are feature tests since it executes directly on the infrastructure. I mean the tests that are testing my code in isolation (coverage, "class configuration" logic) and fully independent from the framework, database, or Temporal itself. |
Why do you need the I think you only need to mock the |
Yeah, but what if someone needs to swap the implementation of the stub builder? I'm used to mocking everything in unit tests. 😄 If you don't want to move in this direction, I don't insist though. Will abstract that on my own. |
I need to think about it for a moment. |
I've made some changes:
Can it work for your use case? |
It's way better now, although not ideal for my case since all the builder fakes would need to be coupled to the concretes, but as you mentioned that would require a review of all used classes and return types in the package, so maybe in the future. :) Thank you for the effort! |
Hi @cappuc!
To be able to use dependency injection instead of facade and test classes in isolation we need an interface for the main
Temporal
class.I haven't added types for those methods since all of them return concrete classes and that would have been a BC break (used generic
object
instead).