c++qtunit-testingboostqttest

Testing the opening of files using QTestLib


I am new to unit testing and the Qt framework. I have been assigned to write a unit test to test the opening of text files.

I have looked the the tutorials for Qt test. But I have no idea how to proceed. (I have to use QTestLib). Please guide me what I should do.

Boost libraries are being used to open the csv and delimited text-files to import the data in the application.


Solution

  • By testing, I am assuming that you want to check if the files are being read properly.

    1) To get a better understanding about the Qt Project structure, check out this link

    2) Locate the class that is actually calling the boost libraries to read the data, you might want to test this class (It depends on you how you want to implement, without any details, I cannot give a better explanation)

    3) Create the corresponding object and invoke the reading of the file. After the file has been read, you can QVERIFY or QCOMPARE the data read by the class and the actual values. To use custom datatypes in the previous functions, look at this link. It is explained in the website, how to create and use custom datatypes for the above functions.

    4) To run multiple tests in a single Test project (Qt), look at this github repo (I'm unable to find the website where it was originally posted).

    I hope this gives an idea of how to get started with writing the test. It really depends on what your requirements are, without knowing the details, I might not be able to help more