I have a need to unit test build logic; not a plug...
# plugin-development
l
I have a need to unit test build logic; not a plugin but logic which operates on Gradle Project objects. Therefore, I have the need to create Project objects within (unit) test scope - and I wonder how to do that “from scratch”. • Mock frameworks seems like a bad idea, because the Project interface is big and has a lot of non-trivial accessors. • GradleRunner seems like a bad idea, because it simply executes Gradle on a set of projects, capturing output and permitting tests on the result of builds. • ProjectBuilder is a too simple tool, because I want to set and access the Project’s Path when calculating some build logic properties. Alas - what should I use to retrieve a Project in test (for which I should test build logic, and which needs to be working decently similar to normal Gradle projects).
v
the last you mentioned.
If you need a specific path, just build it, you can give the project builder the parent project you also built so you can build up and project path you need
l
Let’s see if I follow your logic here. Am I understanding you correctly in that… 1. if I need a project for testing with the path
:flagship:foo:bar:component:component-api
, I would need to 2. Create 5 projects with the name being equal to the gradle path segment, and then 3. Setup their parent-child relationship accordingly?
v
No, with the name being the name. The path comes from the parent/child relation
So one project with name "flagship", one with "foo", and so on, giving the parent to the child builder.
l
Yup. Allright; that was actually what I suggested. (“Path segment” == “Name”) Oki. Doing it.