-
Notifications
You must be signed in to change notification settings - Fork 7
added stencil template files for mocking and randoms generation #14
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
base: reactive-call-broader-support
Are you sure you want to change the base?
Conversation
| import Foundation | ||
| import SwiftyMock | ||
| import Result | ||
| @testable import Betterme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome 👍
but please remove this dependency
btw is it possible to know in stencil what module we're in? like in xcode templates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately I didn't found solution for that yet
| @@ -0,0 +1,51 @@ | |||
| import Foundation | |||
| @testable import Betterme | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately I didn't found solution for that yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass parameter to sourcery script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, just wanted to answer the same :)
there's args that you can pass and read inside
or better - setup yml file with all configs and pass path to it via --config flag
so that it'll contain
args:
testable:
- Bettermeand read as
<%_ if let testable = arguments["testable"] as? String { -%>
<%_ %>@testable import <%= testable %>
<%_ } -%>
| @@ -0,0 +1,54 @@ | |||
| import Foundation | |||
| import SwiftyMock | |||
| import Result | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and guess we don't need Result here as it's imported from ReactiveSwift
|
@vmalakhovskiy Can you please write down how are you using these stencils, may be add sourcery script right to the example itself? |
|
Actually yeah, I'm using sourcery with config file running in watch mode, so it can detect changes in source code or templates and automatically regenerate code.
my config looks like this: sources:
- MyProject
- MyProjectTests
templates:
- MyProjectTests/Templates
output:
path: MyProjectTests/Generated |
|
do we need random implementations? and there're many good tools that are specifically dedicated to randomization |
Polished sourcery templates given in #14
|
I tend to agree Random is useful but orthogonal. However, one important note is that it is not a great idea to use pure random tests. Why? Because if a test fails, you cannot reliably reproduce the failure. Tests should be predictable and reproducible. Proper randomized testing re-uses the same values in the same order each time after (re)generation. This way CI pipeline will always be consistent. You can do that by either saving the actual values used, or by seeding the RNG with the same value (however, not |
|
@adamkaplan agree, I tend to use third-party libraries for randomization, i.e. RandomKit - it can be seeded |
No description provided.