[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Question on QTest::ignoreMessage / qDebug() operation
From:       Manuel Breugelmans <mbr.nxi () gmail ! com>
Date:       2008-08-20 8:38:23
Message-ID: 200808201038.23180.mbr.nxi () gmail ! com
[Download RAW message or body]

On Monday 11 August 2008 13:41:46 Thiago Macieira wrote:
> Brad Hards wrote:
> >G'day,
> >
> >I'm trying to use QTest::ignoreMessage to verify some QDebug output.
>
> Stop. Don't verify qDebug, since those go away in release builds. And
> release builds should not have debugging information.
>
> You can and should verify qWarnings, though.
>
> (The same goes for the kDebug/kWarning versions)

That would be a valuable addition to the QTestLib documentation. Currently it 
implicitly suggests to verify qDebug.

> >It works fine for the qDebug("foo") form, but not for qDebug() << "foo";
> >
> >void Problem::checkIgnoreMessage()
> >{
> >    QTest::ignoreMessage( QtDebugMsg, "Will Work" );
> >    QTest::ignoreMessage( QtDebugMsg, "Wont Work" );
> >    qDebug( "Will Work" );
> >    qDebug() <<  "Wont Work";
> >}
> >
> >Any suggestions?
>
> There's an extra space: "Wont Work ". It's a side-effect of the automatic
> spacing that qDebug does.

If you'd ask me I'd say ignoreMessage is flawed. You want your tests to be as 
robust as possible. 90% of the time they should not be forced to care about 
capitals, punctuation and even less trailing white-spaces in warning messages. 
A version with a QRegExp might solve this.


Manuel

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic