开发者

QT Qtestlib, Unit Test

If I were to create a unit test for class implementation using QTestlib ( trying to figure it out) how would I do it. (I know unit testing for the simple class below can be done other simple way I trying to understand QTestlib framework and whether its 开发者_StackOverflowreally what I want)

Consider a simple class ( just to make things really clear )

//Add.h

class Add {
           public:
           int add (int a , int b);
};


//Add.cpp 

int Add::add(int a, int b)
{
int c=0;
c=a+b;
return c;
}

How should I use QTestlib to test this class? Some info would be great.

If this isnt the right way. Let me know. Also some info on automated testing would be nice.


Take a look at https://doc.qt.io/archives/qt-4.8/qtestlib-tutorial.html, it explains step-by-step how to create a test using QTestLib in a very accessible way.

For Qt versions >= 5, the official Qt Test tutorial can be found at https://doc.qt.io/qt-5/qtest-tutorial.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜