Unit testing (once again)

Milian Wolff mail at milianw.de
Wed Feb 8 17:48:01 UTC 2012


Aleix Pol, 08.02.2012:
> On Wed, Feb 8, 2012 at 5:23 PM, Miha Čančula <miha at noughmad.eu> wrote:
> > 2012/2/8 Aleix Pol <aleixpol at kde.org>

<snip>

> >> To extract the information, the view plugin will load all the plugins
> >> that implement the UnitTestProvider interface and ask for the provided
> >> information. Here's some rough idea of what I think this interface
> >> might have looked like.
> >> 
> >> class Test {
> >>   QString executable(); //maybe a launcher?
> >>   QMap<QString, QStringList> cases(); //test name with the arguments
> >> to pass to the execution
> >> };
> >> 
> >> class IUnitTestProvider {
> >>    virtual QMap<KUrl, Test> retrieveTests() = 0;
> >> };
> > 
> > This is basically what I had in mind, except for the tree structure (and
> > asynchronous operation, and checking whether this particular provider is
> > the right one for a project). My question is where to put the Test
> > class. It's possible to avoid it altogether by replacing it with a
> > QPair<QString, QStringList> or something even more convoluted, but that
> > looks ugly. On the other hand, an ugly typedef is still better than a
> > whole separate library.
> 
> It has to be together with the interface, because the interface
> depends on it. I think it's fine if it's inside interfaces.

Just make it a pure abstract interface as well.

namespace KDevelop {
class ITestSuite
{
  ILaunchConfiguration* launcherForAllCases() const  = 0;
  ILaunchConfiguration* launcherForCase(const QString& case) const  = 0;
  ILaunchConfiguration* launcherForCases(const QStringList& cases) const  = 0;

  QStringList cases() const = 0;

  KUrl url() const = 0;
};
}
Q_DECLARE_INTERFACE(KDevelop::ITest)

And personally, I would rather create a test controller where unit test suites 
can be added/removed. I.e.:

class ITestController
{
  void addTestSuite(ITestSuite* suite);
  void removeTestSuite(ITestSuite* suite);
};

This way plugins can easily add test suites by just implementing a ITestSuite 
class and registering it at the controller.

something like that.

cheers
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20120208/cbf6f609/attachment.sig>


More information about the KDevelop-devel mailing list