Doesn't it make sense to use `scalaProject.withSourceFile` instead? You can get a compilation unit from a path, see `TestProjectSetup`.