Skip to content
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

Allow Jenkins/Java-style class names in JunitReporter #753

Merged
merged 6 commits into from Apr 2, 2019

Conversation

@pzingg
Copy link
Contributor

@pzingg pzingg commented May 5, 2018

I don't know the history of the classnameOK function in the JunitReporter, but I know it causes problems for me when I add testthat reports to my Jenkins JUnit reporter plugin.

In my continuous integration pipeline, my other Jenkins tests use pytest to report out some Selenium end-to-end testing. The JUnit plugin in pytest sets the class names of test cases to a Java-like format: python_module_name.TestClassName. When I try to use this convention in testthat, using, say a call context("test_file_name.TestClassName"), classnameOK replaces the dot character with an underscore, and then the Jenkins reporter web interface puts all of my testthat tests in one huge package named root, rather than keeping them nicely sorted under the test_file_name package.

The version of classnameOK in this PR preserves dots, hyphens, underscores and alphanumerics. All other characters are are replaced with underscores.

@@ -1,8 +1,12 @@
#' @include reporter.R
NULL

#' Strip illegal chars from a context or test_that description string.
Copy link
Member

@hadley hadley Mar 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use regular comments here? I think you should also include a small test so that it's not accidentally broken in the future.

Loading

Copy link
Contributor Author

@pzingg pzingg Apr 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped the roxygen quotes from the comments, and wasn't sure how you would like a test case, but I made an attempt that parses the xml output and checks the "name" attributes in the "testsuite" elements.

Loading

@hadley
Copy link
Member

@hadley hadley commented Apr 1, 2019

Can you please just write a simple test of classnameOK()?

Loading

@hadley
Copy link
Member

@hadley hadley commented Apr 2, 2019

Actually, let me do it.

Loading

@hadley hadley merged commit ea1fc6d into r-lib:master Apr 2, 2019
0 of 2 checks passed
Loading
@pzingg
Copy link
Contributor Author

@pzingg pzingg commented Apr 2, 2019

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants