Wow, this worked fine for me.
I was worried that my unittests should gain access to private class members embedded in other dynamic libraries (.so files), but this is exactly what I need.
I need to declare a flag only in my unit test.so compilers (each test is.so). Even in libraries where accessible objects are defined.
I needed to access the internal widgets in the form in order to fill in their values; they are not visible to the rest of the program, but are necessary if my tests introduce a user entering input. Just thought that I would share a precedent for those who have access to private access :)
Also for completeness, here is my form class showing the private name_ field:
struct EditProduct : public widgets::BusinessObjForm<model::Product> { public: EditProduct (WContainerWidget *parent=0); protected: void fillObjFields(); private:
and here is the beginning of my unit test access to this widget:
BOOST_AUTO_TEST_CASE( form_save_test ) { EditProduct form(app.root()); string txt = "this is a product"; form.name_->setText(txt); BOOST_CHECK_EQUAL(form.name_->text(), txt); }
matiu
source share