Skip to content

Reporters refactoring #215

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

Closed
hadley opened this issue Jan 9, 2015 · 6 comments
Closed

Reporters refactoring #215

hadley opened this issue Jan 9, 2015 · 6 comments

Comments

@hadley
Copy link
Member

hadley commented Jan 9, 2015

  • Separate data capture from display. A reporter should just be a set of callbacks that are triggered (before/after x suite, context, test, expectation). This should considerably simplify the reporter code, and would eliminate the need for a separate ListReporter)
  • Use R6 instead of RC (so they can be more easily extended from outside the package).
@hadley
Copy link
Member Author

hadley commented Feb 21, 2015

Use the condition system to elimate the existing global state

@lentils
Copy link

lentils commented Mar 24, 2015

Hi @hadley I am interested in capturing the failures printed to STDOUT so I can do some further analysis in R. Looking at test_file, a lot of the functionality is already there (courtesy of SummaryReporter), but there are 2 problems:

  • test_file doesn't return the failure reasons associated with each tests (what I'm looking for)
  • a dataframe's flat structure isn't appropriate for reporting failures from multiple expectations

Ideally, there would be a reporter that returns a list instead of a dataframe. It's important enough to me that I'm considering making a PR for this, but this issue makes me wonder if I should wait until after refactoring. So I guess my question is: will the refactoring work you suggest make this type of reporting easier and is it worth it to mess with reporter methods at this point?

Thanks for a great package. Looking forward to updates in the future.

@hadley
Copy link
Member Author

hadley commented Mar 30, 2015

Yes, this refactoring will definitely do what you want. But it's unlikely that I'll have time to work on it before May at the earliest.

@lentils
Copy link

lentils commented Mar 31, 2015

That's great! I have been trying to hack together some workaround for this feature without much success. I am in the process of thinking about how to start, but I'm not sure where to begin. Since this is a feature I could use, I would be happy to work on it with your suggestions.

@timvink
Copy link

timvink commented Jul 15, 2015

@lentils here is some code to help you capture the output:

library(stringr)
library(data.table)
library(magrittr)

# run tests and save results
errors <- capture.output(results <- test_dir("##Your dir with tests##", reporter = 'summary'))

# parse errors
failure <- grep("Failure",errors) # get vectors with failure tests
failure <- sort(c(failure,grep("Failure",errors)+1,grep("Failure",errors)+2)) # add vectors with failure test descriptions
failure <- errors[failure]
failure <- str_replace_all(failure, "-+$","") %>% str_replace_all("^[0-9]+. \\w+ \\(at \\w+.R\\#\\d+\\): ", "")
failures <- data.table(Test=failure[seq(1,length(failure)-2,3)], Failure=failure[seq(2,length(failure)-1,3)], Details=failure[seq(3,length(failure),3)])
failures[,Details := str_extract(Details, "[0-9]+$")]

# parse results
results <- as.data.table(as.data.frame(results))
results <- results[, .(context, test, checks=nb, failed, time=real)]

@hadley
Copy link
Member Author

hadley commented Feb 29, 2016

Reporters have been cleaned up a lot - I no longer there's much point in refactoring to switch to using the condition system.

@hadley hadley closed this as completed Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants