Hi,

Thank you very much for such a nice and simple unit test framework.

I have been trying to integrate the unittest++ output into QtCreator 
IDE, on linux.
I found that there is subtle difference between unittest++ output and 
gcc output on linux,
and due to that QtCreator IDE was failing to recognize the unit test 
failures as build issues.

I have made some small changes in TestReporterStdout.cpp to make error 
message to include a dummy column number
and to write the error message to stderr instead of stdout.
It is working for me on linux-gcc and I am able work with QtCreator and 
Unittest++ smoothly.
I came to know that there are many people who are interested in this, 
and have used different methods to achieve this form here
http://qt-project.org/forums/viewthread/1235/ .

Even though my changes are working fine for me, I am not sure whether it 
would break any other IDEs.
So it would be great if some one could review this patch. Please let me 
know your comments as well.


diff --git a/UnitTest++/src/TestReporterStdout.cpp 
b/UnitTest++/src/TestReporterStdout.cpp
index 563113c..96f725a 100644
--- a/UnitTest++/src/TestReporterStdout.cpp
+++ b/UnitTest++/src/TestReporterStdout.cpp
@@ -13,13 +13,13 @@ namespace UnitTest {
  void TestReporterStdout::ReportFailure(TestDetails const& details, 
char const* failure)
  {
  #if defined(__APPLE__) || defined(__GNUG__)
-    char const* const errorFormat = "%s:%d: error: Failure in %s: %s\n";
+    char const* const errorFormat = "%s:%d:%d: error: Failure in %s: %s\n";
  #else
      char const* const errorFormat = "%s(%d): error: Failure in %s: %s\n";
  #endif

         using namespace std;
-    printf(errorFormat, details.filename, details.lineNumber, 
details.testName, failure);
+    fprintf(stderr, errorFormat, details.filename, details.lineNumber, 
1, details.testName, failure);
  }

  void TestReporterStdout::ReportTestStart(TestDetails const& /*test*/)


Thanks,
Lijo

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
unittest-cpp-devel mailing list
unittest-cpp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unittest-cpp-devel

Reply via email to