Question

As is sometimes usual in visual applications, I have some code where data is maintained in a visual component (a TTreeView component). I'm refactoring the code and creating unit tests for the logic.

The only visual form in my test project is the GUITestRunner. In the future I plan to run the tests as a console application under a continuous integration server, so I won't have any form.

When I try to create a TTreeView widget without a parent and use it, I get the following error:

Control '' has no parent window

What's the best way to create the widget on my test suite SetUp method and destroy it in the TearDown? Is it possible to use a visual widget in a console application? I don't need to display it, or even process events. I just have to create child nodes and access the data.

I managed to make it work with an ugly hack, but I'd like to know if there is some standard practice.

Sure, in my sunny and distant future, I'll refactor the code of this 21 thousand lines form, all my data will be in beautiful data structures and these kind of tests won't be necessary, but now I need it.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top