Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Unit Test Plugin
koonschi:
Hello,
I'm currently writing a UnitTest plugin based on UnitTest++. There are already means to execute unit tests by adding them as a post build command.
While this works fine most of the time, I was still unsatisfied with it.
The motivation was to start unit tests from the IDE, like, for example JUnit or VS are doing it. Basically, right-click into the editor "UnitTest" -> "Run current test" or "Run current test suite".
It's meant to work like this when it's done:
The user creates a Test Project. This test project has a predefined main.cpp, which parses command line options and then runs tests based on the input from the command line.
This main.cpp is not meant to be manipulated (but can be nevertheless ofc).
Then you only have to add new files with tests and test suites a la UnitTest++. You can either run them all at once (simply build & run the project), or you can run them selectively from codeblocks.
I also want some kind of test list, where you can see what tests or suites there are and then run them from there. I'm basically thinking of something similar to the VisualStudio 2010 interface.
I've been using UnitTest++ for quite some time now and I've made a few adjustments to it over time, in order to report better error messages, more means for checking values or for comparing stl containers.
What I got to work so far:
* RMB -> Unit Testing -> Run Test
* RMB -> Unit Testing -> Run Suite
* RMB -> Unit Testing -> Run All Tests
* Running tests compiles the test program first
* Test output gets displayed & parsed by the plugin (similar to compilation output)
* Double click on a test failure jumps to the file + line where it failed
What's still to do:
* Logging of test results
* List containing all tests of one or more projects
* List with failed or successful tests
* Code Coverage (gcov)
* Comfort functions like 'create a new test file'
* Polishing
Screenshots so far:
http://i.imgur.com/zhuYek7.png
http://i.imgur.com/Ecytzof.png
http://i.imgur.com/gNXcGya.png
My biggest concern is, that the plugin requires the adjusted version of the UnitTest++ framework, because a test project of the plugin must be based on the UnitTest++ framework. Otherwise the plugin can't parse the Tests and Suites or the output.
Would it work if the plugin simply creates a test project that already contains, say, 25 files (== the UnitTest++ files)?
I'd be happy to hear what you think.
Edit: Attached source.
oBFusCATed:
I've not read it all, but I'm sure I don't like it because:
1. the right click menu is already too cluttered and you're adding stuff too it
2. the same for logs&messages
3. unittest++ only dependency (I'm using it, but there are plenty of other testing frameworks that many people use)
4. the project automagic will break too easily :)
stahta01:
FYI: If you plan to have it added to the CB Official Contrib, at current time the CB Team is NOT doing C++11 needed for override and for range.
Attached a windows cbp project; has untested Unix part.
Tim S.
koonschi:
--- Quote ---1. the right click menu is already too cluttered and you're adding stuff too it
2. the same for logs&messages
--- End quote ---
I agree with you, and I'm planning to only let the right click menu appear when you right click into a file that contains tests.
If you have a better idea for displaying test output, I'd be happy to hear it. For now this was the quickest solution.
--- Quote ---3. unittest++ only dependency (I'm using it, but there are plenty of other testing frameworks that many people use)
--- End quote ---
I'm aware of that, but I think the lack of integrated unit test support is quite a big issue.
--- Quote ---4. the project automagic will break too easily :)
--- End quote ---
I think I don't understand?
killerbot:
the log and messages is ok for me. (see remark at the end)
But the right click menu is indeed to cluttered, ideas :
- submenu in Build menu ( or project menu ?)
- a dedicated menu (next to (right hand side) Debug)
- colors : green and red : number of tests, failures / success / ...
Indeed in such a case one wants to have the unit tests "library" present. I think "according to the licensing" we might bundle the sources and have the lib as part of CB.
It is a small a nice framework, good thing to start with and have something in the IDE. Once we have something we could make it more generic, one can think of cppunit, google test etc ...
But step by step ...
If we think we have too much messages, then we should :
- build log / build messages
- valgrind log valgrind messages
- cppcheck log / cppcheck messages
- unit test log / unit tests messages
...
The nthey all should go to one instance of :
- foo log / foo messages
where I have no clue yet on how to call 'foo' ;-)
Navigation
[0] Message Index
[#] Next page
Go to full version