Fwd: Testing Private Methods

jan iversen jani at documentfoundation.org
Sat May 21 13:55:38 UTC 2016


Hi

Calling for the help of core developers, I recieved this email in private. I am not sure what the correct answer is, so please give me a hand.


> Hey Jan,
> 
> I'm trying to test a private method for Writer in hopes of increasing coverage a little. The Readme says that sw/qa/core/uiwritter.cxx has access to private symbols, but I can't seem to get my test working. I keep getting this typical CPP error message when compiling:
> 
> /home/adam/libreoffice-source/core/sw/qa/core/uwriter.cxx: In member function ‘void SwDocTest::testTableCellComparison()’:
> /home/adam/libreoffice-source/core/sw/qa/core/uwriter.cxx:1634:82: error: ‘sw_CompareCellsByRowFirst’ was not declared in this scope
>     CPPUNIT_ASSERT_EQUAL(sw_CompareCellsByRowFirst(OUString("A1"), OUString("Z1")), 0);
> 
> Should I not be testing private methods? Or am I doing something wrong here? Am I not importing the right files?
Every test is POSITIVE, so yes in my opinion you should.

You need to declare the test class "friend" of the implementing class, that would solve the problem, however I am unsure how we do this in general, so please read answers from others.

rgds
jan I.


More information about the LibreOffice mailing list