Review Request: SoK - Unit Test : core/collections/support/TrackForUrlWorker

Matěj Laitl matej at laitl.cz
Thu Jul 5 21:29:13 UTC 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/105389/#review15417
-----------------------------------------------------------


Good direction, but needs some work to test TrackForUrlWorker in a "natural" (close to real usage) way.


tests/core/collections/support/TestTrackForUrlWorker.h
<http://git.reviewboard.kde.org/r/105389/#comment12051>

    Code style: our includes are in "", not in <>



tests/core/collections/support/TestTrackForUrlWorker.h
<http://git.reviewboard.kde.org/r/105389/#comment12052>

    Why these are public? Data members should be normally private.



tests/core/collections/support/TestTrackForUrlWorker.h
<http://git.reviewboard.kde.org/r/105389/#comment12053>

    Why this is a slot? That way it looks like a testfunction.



tests/core/collections/support/TestTrackForUrlWorker.h
<http://git.reviewboard.kde.org/r/105389/#comment12054>

    Hmm, if this is a private slot, it looks like a testfunctin that QtTest wants to execute. This _should_ normally be a private slot, but in test I would make it public slot so that it is clear that this isn't a testfunction.
    
    Also, please name your methods more descriptively, I would name this: "setEmittedTrack"



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12064>

    I don't see any sense having useless MockTrackForUrlWorker and subclassing it in TestingTrackForUrlWorker. I would put the run() method you implemented here directly to MockTrackForUrlWorker.



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12063>

    You don't need this, see below.



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12062>

    You don't need this method at all.



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12065>

    testCompleteJobKUrl_data() and testCompleteJobQString_data() can share code, too, I suggest non-slot private testCompleteJobInternal_data()



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12067>

    No, please do it like in real TrackForUrlWorker life: enqueue the job using ThreadWeaver::Weaver::instance()->enqueueJob() and then wait for the done signal using kWaitForSignal(). ThreadWeaver emits the signal for you, so you can avoid hacky emitDone().



tests/core/collections/support/TestTrackForUrlWorker.cpp
<http://git.reviewboard.kde.org/r/105389/#comment12066>

    No need to call trackForUrlWorker->track, instead QFETCH( Meta::Track, track )



tests/mocks/MockTrackForUrlWorker.h
<http://git.reviewboard.kde.org/r/105389/#comment12068>

    As I said above, I would put TestTrackForUrlWorker::run() implementation here and get rid of TestTrackForUrlWorker completely, otherwise this class usefulness approaches zero.


- Matěj Laitl


On July 5, 2012, 12:07 a.m., Jasneet Bhatti wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/105389/
> -----------------------------------------------------------
> 
> (Updated July 5, 2012, 12:07 a.m.)
> 
> 
> Review request for Amarok, Matěj Laitl and Sven Krohlas.
> 
> 
> Description
> -------
> 
> Added unit test for core/collections/support/TrackForUrlWorker
> 
> Just the one slot completeJob() to test.
> Tested for both KUrl and QString types of urls.
> 
> 
> Diffs
> -----
> 
>   tests/core/collections/CMakeLists.txt b01b655 
>   tests/core/collections/support/CMakeLists.txt PRE-CREATION 
>   tests/core/collections/support/TestTrackForUrlWorker.h PRE-CREATION 
>   tests/core/collections/support/TestTrackForUrlWorker.cpp PRE-CREATION 
>   tests/mocks/MockTrackForUrlWorker.h PRE-CREATION 
>   tests/mocks/MockTrackForUrlWorker.cpp PRE-CREATION 
> 
> Diff: http://git.reviewboard.kde.org/r/105389/diff/
> 
> 
> Testing
> -------
> 
> Builds and runs fine.
> 
> 
> Thanks,
> 
> Jasneet Bhatti
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/amarok-devel/attachments/20120705/10468741/attachment-0001.html>


More information about the Amarok-devel mailing list