> In R/test-files.r:
>
> >  #' @export
> >  test_dir <- function(path, filter = NULL, reporter = "summary", env = NULL) {
> > -  reporter <- find_reporter(reporter)
> > +  current_reporter <- find_reporter(reporter)
>
> I think of find_reporter() as being a reporter factory - it should return
> something that meets the requirements you want, but it doesn't need to
> specify exactly the class of the returned object.
>
Yes, exactly, that's a factory. But I still do not quite understand what
you suggest to do.
In your opinion, what should return

 - find_reporter('summary') ? a SummaryReporter, a MultiReporter or a
Lister Reporter
 - find_reporter() ?


For the implementation of test_dir(), we need to have both the
MultiReporter and the ListerReporter instances available.
What could be done, and maybe was your point, is for find_reporter to
return a MultiReporter in case it is given more than one reporter.
e.g.
 - find_reporter('summary') ==> SummaryReporter instance
 - find_reporter(current_reporter, lister_reporter) ==> a MultiReporter
instance, containing the  2 reporter objects

The current block:
    current_reporter <- find_reporter(reporter)
    lister <- ListReporter$new()
    reporter <- MultiReporter$new(reporters = list(current_reporter,
lister))

would become:
  lister <- ListReporter$new()
  reporter < find_reporter(reporter, lister)

so it would save one line... adding a lot more complexity. Do you foresee
use cases for this improved find_reporter() ?



> —
> Reply to this email directly or view it on GitHub<https://github.com/hadley/testthat/pull/98/files#r7526187>
> .
>