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

Projects
None yet
2 participants
@pzingg
Copy link
Contributor

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.

This comment has been minimized.

Copy link
@hadley

hadley Mar 31, 2019

Member

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.

This comment has been minimized.

Copy link
@pzingg

pzingg Apr 1, 2019

Author Contributor

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.

@hadley

This comment has been minimized.

Copy link
Member

commented Apr 1, 2019

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

@hadley

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

Actually, let me do it.

hadley added some commits Apr 2, 2019

@hadley hadley merged commit ea1fc6d into r-lib:master Apr 2, 2019

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@pzingg

This comment has been minimized.

Copy link
Contributor Author

commented Apr 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.