Testing on Dspace
-----------------
Key: DS-532
URL: http://jira.dspace.org/jira/browse/DS-532
Project: DSpace 1.x
Issue Type: Improvement
Components: DSpace API
Affects Versions: 1.6.0
Environment: Any
Reporter: Pere Villega
Priority: Minor
Attachments: DSpace-1.6-jmeter.jmx, mvn_reports.patch, tests.patch
Hi everybody,
I'm writing on behalf of Enovation Solutions. After contacting Tim Donohue and
Stuart Lewis, we did a bit of work on testing for DSpace. What I send you now
is, as commented to Tim Donohue and Stuart Lewis, some scaffolding that can
allow others to continue. I send the current files so you can validate and
comment on them. Be aware this is a initial work, to see how feasible is to
integrate unit testing on Dspace, detect any possible issues and provide a
platform to start developing more cases.
I've submitted a GSoC 2010 proposal to continue on this work in a personal
basis, as Enovation will gladly support my efforts on this. If you find it
interesting and useful, please consider the proposal.
We have created 3 components for DSpace, which I list next with some comments
on each:
1) JMeter
It was mentioned by Tim Donohue and Stuart Lewis that some JMeter scripts for
both regression and performance testing would be interesting, so we have
created a script for that (see attached file Dspace-1.6-jmeter.jmx)
The script includes:
- Testing for a vanilla JSPUI dspace (deployed with no data at all)
- Testing for a vanilla JSPUI dspace (deployed with some data)
- Testing for OAI-PMH (deployed with some data)
The script is properly parametrised so you can run it from command-line in a
continuous integration environment.
Be aware JMeter is focussed on performance testing more than regression, so
the script does a fairly basic test by checking that the main links of DSpace
don't return any error, and by verifying they contain expected fields and data.
It can't manage submission of items or other similar forms in enough detail to
be more useful, but should be enough for a quick validation check.
At a later stage we will probably develop some Selenium scripts for functional
testing on DSpace, but this is a work in progress and will take a while (can't
give any realistic estimate on it).
2) Maven reports
We have created a patch (maven_reports.patch) that adds some reporting to
DSpace. This is important if unit testing classes will be created, as it gives
an image of the coverage of the tests and the overall quality of the code. The
reports integrate with the maven site and can be generated by running: "mvn
site"
We have included the following reports:
1- Cobertura: shows which % of the classes is covered by unit tests
2- Testability explorer: displays how testable are the classes of DSpace and
what should be fixed
3- Tag list: lists all the TODO/FiXME/@todo notes in the code
4- Surefire: generates reports on unit tests run
5- PMD and CPD: checks the source code for bugs/bad practices and duplicated
code (probably from copy-paste)
6- Findbugs: Locates bugs/bad practices in the code
7- Maven changes: links to JIRA to show the changes done to this project
The first 4 are really important when creating unit testing, and the next two
(5 and 6) are quite good at catching issues in the code.
While developing this we dectected a problem with the reporting in DSpace. Due
to the way Maven subprojects work and the hierarchy of subprojects in Dspace,
most of these modules can't aggregate the reports, so the report will be
created for each subproject that has some java classes instead of having one
unique report with all data.
There is a solution to this, which is the use of Sonar
(http://sonar.codehaus.org/). Sonar is an open source web application that
automatically inspects and performs some analysis on the projects, attaching
automatically the configuration for many Maven 2 plugins (like Cobertura) to
the projects. It can also link to JIRA and some continuous integration systems.
You can see an example at their demo site Nemo (http://nemo.sonarsource.org/)
We strongly suggest to install it as it will provide a clear image of the
status of the unit testing efforts and will reveal issues in the code. We can
provide help installing Sonar on any server you may have available if required.
3) Unit tests
We have created some unit tests, using JUnit 4.7 and Mockito
(http://mockito.org/). This is a work in progress and you will see the current
tests are minimal, more of a proof of concept.
The patch is in file tests.patch, and it will run the tests from both Maven and
the IDE. You will notice some tests are giving errors, that's done in purpose
to
highlight some issues.
About the unit testing effort, we have noticed by running the reports on point
2 that DSpace suffers from many testability issues. Many classes are not easily
testable using unit tests (for example, Context). It would be advisable to
refactor all these classes, as it will increase the quality of the DSpace code.
The downside is that it will break compatibility with previous versions of the
API.
In the GSoC proposal I've commented on this issue. Refactoring of the code
(starting with the core API and moving up to the other services) to follow
Demeter's Law (http://en.wikipedia.org/wiki/Law_of_Demeter) should be feasible
during the GSoC, would improve the code quality and would allow contributors to
create more unit tests easily. It would also allow the use of frameworks like
Guice or Spring for dependency injection, making code clearer and more
maintainable. We could just throw extra unit tests into Dspace, but thinking in
the long term, this is not a good idea, although if it's the choice of the
community, it can be done with some workarounds for the testability issues.
That would be everything by now. I hope you find these contributions useful. As
was mentioned above, they are work in progress, a foundation stone that we
will try to grow as time goes. I'm at your disposition if you want to discuss
anything related to the contributions or unit testing.
Best regards,
Pere Villega
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel