-
Notifications
You must be signed in to change notification settings - Fork 260
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
feature: WIP: Subject code generator, fixes #612 #894
Conversation
Generates the bare bones boiler plate subject for later extension. Needs several usability improvements to make it practically accessible.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
…ge systems Choose which style to use - Boiler plate dump - generates everything we have in one file and overwrites everything on subsequent runs - Three layer keeps user code as separate as possible from generated code - Merge system attempts to merge user and generated code
…ge systems Choose which style to use - Boiler plate dump - generates everything we have in one file and overwrites everything on subsequent runs - Three layer keeps user code as separate as possible from generated code - Merge system attempts to merge user and generated code For all the above options, also generates a class as a single point for all the managed Subjects.
FYI, needs more work of course, but I know have a 3 class system,
All generated assertion entry points get collected into a And have started experimenting with some basic test generation. It's all generated except for:
|
…enums, arrays, etc etc
…urce control under new package
Ok, it's mostly ready to look at now. I'm at my personal MVP and will start using it in my projects. |
this(packageFromClass.getPackage().getName()); | ||
} | ||
|
||
public void generateAllFoundInPackagesOf(Class<?>... classes) { |
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.
rename from generate verb (as it doesnt yet), to something like 'add'
import static com.google.common.truth.Truth.assertThat; | ||
|
||
@RunWith(JUnit4.class) | ||
public class TruthGeneratorTest { |
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.
adopt project naming style
|
||
@RunWith(JUnit4.class) | ||
public class TruthGeneratorTest { | ||
|
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.
need to make sure test suite works as a whole
Converted back to draft. Will mark ready again when: |
Hi @cpovirk , is it possible to get CI turned on for this PR? Or am I barking up the wrong tree here.. :) |
Markers for factory methods - not used yet Markers for bae subject extensions - not used yet
FYI, this is what some of the generated output looks like: https://github.com/astubbs/truth/blob/generator/extensions/generator/src/test/resources/expected/MyEmployeeParentSubject.java.txt |
…boolean name collisions
heya @cpovirk , or anyone out there - if I could get an indication if there is any interest in merging this? Otherwise, I'll put effort into releasing it myself as a seperate project. But would rather not double up. |
Sorry, we keep saying that we need to write down the meanings of our priority labels, but we keep not doing so. "P3" == "not scheduled," so I would be happy to see such a thing released separately so that it exists and we can point people to it, rather than having it wait here indefinitely. |
Thanks Chris! Ok sweet as - shouldn't be too much work to migrate. Just the publishing part is a PITA :) |
Ok @cpovirk - initial refactored version is here: https://github.com/astubbs/truth-generator |
The plugin is now available in a couple of Maven repositories (but not repo1 yet), and the README has been updated with feature list and examples. See the README for details. |
An implementation of #612 Consider auto-generating assertThat and subject factory for custom subjects
Generates the bare bones boiler plate subject for later extension.
Needs several usability
Issue with this, is if you use the pattern of extending the generated classes - the accessor methods return itself, not the class you've extended. Still super useful to bootstrap many model classes. There may be a way around this - need to think about it. Otherwise, Roaster also allows modifying existing classes - so could try experimenting with mutating existing classes, instead of overwriting them - this will preserve the custom assertion methods added to the class after it's first generated.
Features (done):
More (done):
More (done):