Bug 39749 - calc unit test writing
Summary: calc unit test writing
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Spreadsheet (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: EasyHack DifficultyBeginner SkillScri...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 02:03 UTC by Björn Michaelsen
Modified: 2013-12-24 02:46 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Björn Michaelsen 2011-08-02 02:03:18 UTC
==== calc unit test writing ====

'''Background:''' We have a new prototype unit test framework in LibreOffice. The first set of tests is in sc/qa/unit/ and needs your love and attention. We should add new unit tests for each significant C++ class, verifying functionality. Some ideas would be: testing formula parsing (with awkward corner cases etc.), creating large spreadsheets eg. chains of single-cell references, or chains of small range references, and ensuring re-computation dependencies work. It would also be good to have some data-pilot regression tests, and so on.

'''Skills:''' simple C++ programming
Comment 1 Markus Mohrhard 2011-11-01 19:53:24 UTC
adding some more information to reflect our new test desgin in calc:

http://comments.gmane.org/gmane.comp.documentfoundation.libreoffice.qa/42

We have now additionally the possibility to load documents and test the sheet content through a csv file or some code. Several test documents are already created but still need a lot of love. They can be found at: http://cgit.freedesktop.org/libreoffice/core/tree/sc/qa/unit/data/

Skills for this task: knowledge about calc, maybe reading OpenFormula Spec and OpenOffice/LibreOffice documentation/help
Comment 2 Florian Reisinger 2012-05-18 09:10:21 UTC
Deteted "Easyhack" from summary
Comment 3 Björn Michaelsen 2013-10-04 18:47:22 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 4 Ravi 2013-12-24 01:30:18 UTC
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.

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?".

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.

Thanks and Regards
Ravi Mandliya
Comment 5 Markus Mohrhard 2013-12-24 02:46:58 UTC
(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.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.