[Bug 39749] calc unit test writing

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Dec 23 18:46:58 PST 2013


https://bugs.freedesktop.org/show_bug.cgi?id=39749

--- Comment #5 from Markus Mohrhard <markus.mohrhard at googlemail.com> ---
(In reply to comment #4)
> Hi 
> 
> I am a student at clemson university, and I would really really like to
> contribute on this one.This is my first interaction with any open source
> project. I have worked on personal C++ projects, and have good grip on
> language.  The following link mentioned in first comment -
> http://comments.gmane.org/gmane.comp.documentfoundation.libreoffice.qa/42 
> says "No such message". 
>  
> So far:
> 
> 1. I have downloaded and build libreoffice.
> 
> 2. I have looked into "sc/qa/unit/" folders and tried to understand already 
> built unit tests.  
> 
> 3. I understand that the "helper" folder contains the handler files which
> loads csv test data (from "data" folder) and run thesetests.

Great. These are already the most important steps.

> 
> 4. However, I am still not sure, how exactly these unit tests are run, where
> is the main function,how to load the data?. A little help or a link to
> document where this is explained would be of awesome help. My question is
> "How exactly do we run these unit tests?".

They are controlled by the makefiles in sc/. sc/Module_sc.mk contains which
tests are actually included and the corresponding makefiles in sc/ how to build
them.

The main function is in sal/ inside the cppunittester applciation but we don't
touch that part of the code when we write tests. The cppunittester is included
into the test through the CPPUNIT_PLUGIN_IMPLEMENT macro and the remaining
cppunit macros register the tests in cppunit. More information abotu cppunit
can be found at http://people.freedesktop.org/~mmohrhard/cppunit/index.html

So most of the file loading is already abstracted and hidden behind some layers
in our testing framework. You need to follow the different class hierarchy that
goes into test/ and unotest/. Depending on the test we either use direct calls
to the Libreoffice code or use the public UNO API.

Taking sc/qa/unit/filters-test.cxx as an example and picking testRangeNameODS
which tests the import of range names from ODS. Test method is declared in line
63, added to the test suite in line 84, and definition starts in line 224. The
first call in that method loads the file and returns the corresponding
ScDocShell (an internal representation of a calc document).

Sadly there is not much documentation except for
https://wiki.documentfoundation.org/Development/Calc_Import_Unit_Tests which I
wrote when i first implemented the csv based document comparison. Most of this
page should still be correct.


> 
> I really intent to contribute and learn. I am a quick learner, and I really
> find it interesting. I would really appreciate some pointers. Like where
> exactly the class files located, for which we are building test cases?, some
> example test cases for any other module we have.
> 

So these are not real unit tests and we don't test single classes. You can call
it regression testing or integration testing. Basically we normally try to test
the correct interaction of larger pieces of the code. Testing single classes is
nearly never possible in our code base. There are some exceptions for lower
levels where we have real unit tests (also the sc_rangelst_test does something
similar). So normally we test parts of sc/source/core or sc/source/filter or
both together.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20131224/5d4f099b/attachment.html>


More information about the LibreOffice mailing list