Skip to content

Access to Filer, assert about generated files #58

Description

@JakeWharton

Access to the Filer is trivial to add to CompilationRule. What I can't figure out is how to propagate the generated content back to the test to assert on the generated sources. At the very least it would require a change to Compilation to inject the InMemoryJavaFileManager so it could also be made available to the test but that brings other dependencies with it. Perhaps Compilation should be more stateful than just static helpers?

I'm not doing any actual compilation. I want to only test interactions with a Filer and assert on its outputs.

Happy to implement, just want guidance/approval on the approach.

Activity

  1. JakeWharton commented on Dec 17, 2014

    @JakeWharton
    ContributorAuthor

    I ended up writing my own based on JavacPathFileManager and Jimfs. Do with this as you please.

  2. gk5885 commented on Dec 17, 2014

    @gk5885
    Contributor

    Yes, that's totally the right way to go. If you are just testing the filer, make a fake filer - getting the one from CompilationRule is a little weird anyway since that's all part of a fake compilation that actually encloses the test. If you're on 1.7+, JavacPathFileManager and Jimfs are definitely preferred to my semi-hacky implementation.

  3. stephanenicolas commented on Jun 2, 2015

    @stephanenicolas

    Hi @JakeWharton and @gk5885 ,

    do you have a working example of this ? I don't only want to compile the generated code, I would also like to execute it (load it into memory, even if by reflection).
    Follows up #70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions