开源软件名称(OpenSource Name):psexton/matlab-xunit开源软件地址(OpenSource Url):https://github.com/psexton/matlab-xunit开源编程语言(OpenSource Language):MATLAB 87.1%开源软件介绍(OpenSource Introduction):matlab-xunitxUnit for MATLAB with JUnit-compatible XML output READMETesting is wonderful! Let's make it easier and more rewarding! The most popular testing platform for MATLAB functions and classes is/was Steve Eddins' excellent MATLAB xUnit package. The previous maintainer, Thomas Smith, made two additions to that package: the ability to give output in a JUnit-compatible XML format, and the ability to run DocTests, similar to the I've made one additional change: renaming Other contributors have added compatibility with R2016b and newer, bug fixes, and internal refactorings. Installation and UsageTo install matlab-xunit, clone or download this from GitHub, and put the Once you've written some unit tests (see xUnit's help), you can then run:
If everything goes well, you'll see some output like this:
If any of the tests failed, they'll be marked with a XML OutputWhy would you want to do that? Well, because other tools understand it. In particular, I'm using the Jenkins continuous integration system (http://jenkins-ci.org/) to automatically run unit tests when I check in code. Jenkins understands JUnit's XML report format, and can display it in very nice ways. By creating a test report file in the same format, we can leverage all of that. For example, here's a screenshot of the table Jenkins generates from a single build's report: And here's a graph of the test trend: The implementation is based on xml_io_tools by Jaroslaw Tuszynski, which is a nice way to generate XML in MATLAB. It uses about 1/3 the lines of code as MATLAB's built-in UsageOnce you've written some unit tests (see xUnit's help), you can then run:
Unsurprisingly, this will run your unit tests and put the results into Usage with JenkinsOK, this is really cool, but involves some setup. First, you're going to have to either install Jenkins on the machine that has MATLAB, or give Jenkins remote access to that machine (there may be MATLAB licensing issues to this, I have no idea). As a note, installing Jenkins is incredibly easy: you download one file and run one command. Now, you need to create a job that checks out your code from Subversion or whatever, and then runs your tests. I'm not going to run you through the whole thing, but here are the two important points: First, you need a build step that will run the tests. Mine looks something like this:
And second, you need to check the Jenkins box that says "Publish JUnit test result report." I tell it to look at Now save the configuration, tell the project to Build Now, and you should have a lovely display of what tests were run, and which failed! DocTestsAs of version 4.0.0, DocTests is no longer part of the "core" matlab-xunit and lives in its own repository at matlab-xunit-doctests. VersioningThis codebase is over 5 years old now, and has had several maintainers, so past versioning is kind of a mess. Starting with version 4.0.0, it follows Semantic Versioning for versions, and Semanticly Versioned Names for tags and releases. Contributing
Suggestion: Please try to keep contributions to one {bug fix, feature, etc} per pull request. If you've got 3 unrelated bug fixes, submit 3 pull requests. If I can read through your changes in < 5 minutes, I'll probably merge it immediately. If it's a huge patch that touches dozens of files for multiple reasons, I'll probably put off merging it until I can do a more thorough code review. And then it will drop off my mental radar. (But not because I don't like you!) License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论