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

List:       kwin
Subject:    Re: Review Request: I call this one "why unit tests are pointless"
From:       Martin_Gräßlin <kde () martin-graesslin ! com>
Date:       2013-01-08 8:30:55
Message-ID: 20130108083055.13011.83401 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On Jan. 8, 2013, 6:25 a.m., Martin Gräßlin wrote:
> > it should go into master, not 4.10.
> > 
> > Oh and it doesn't show that unit tests are pointless, it just shows that this had \
> > not been tested. Here's the test for it: 
> > 
> > diff --git a/kwin/tests/test_virtual_desktops.cpp \
> > b/kwin/tests/test_virtual_desktops.cpp index 36e7933..52a93e0 100644
> > --- a/kwin/tests/test_virtual_desktops.cpp
> > +++ b/kwin/tests/test_virtual_desktops.cpp
> > @@ -287,6 +287,7 @@ void TestVirtualDesktops::testDirection(const QString \
> > &actionName) vds->initShortcuts(keys.data());
> > QAction *action = keys->action(actionName);
> > QVERIFY(action);
> > +    QVERIFY(static_cast<KAction*>(action)->isGlobalShortcutEnabled());
> > action->trigger();
> > QCOMPARE(vds->current(), result);
> > QCOMPARE(functor(initCurrent, wrap), result);
> > @@ -571,6 +572,7 @@ void TestVirtualDesktops::switchToShortcuts()
> > const QString desktop(toDesktop.arg(i));
> > QAction *action = keys->action(desktop);
> > QVERIFY2(action, desktop.toUtf8().constData());
> > +        QVERIFY(static_cast<KAction*>(action)->isGlobalShortcutEnabled());
> > action->trigger();
> > QCOMPARE(vds->current(), i);
> > }
> > 
> 
> Thomas Lübking wrote:
> Sorry, mechanically entered 4.10.
> 
> -- OT --
> 
> Actually that's what i meant - you don't test whether the code works, but whether \
> your test works. The more complex the tested modules input becomes, the less \
> reliable such test will be (action->trigger() works, but has nothing to do with the \
> intended usage - your fix extends the test by an unrelated feature) 
> I don't actually query the unittesting in general to eg. figure whether a function \
> does calculate / return correctly.

yes from that perspective you are of course right.


- Martin


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


On Jan. 8, 2013, 7:24 a.m., Thomas Lübking wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/108253/
> -----------------------------------------------------------
> 
> (Updated Jan. 8, 2013, 7:24 a.m.)
> 
> 
> Review request for kwin and Martin Gräßlin.
> 
> 
> Description
> -------
> 
> and it will absolutely end up in the git history by this description =P
> 
> 
> This addresses bug 312835.
> http://bugs.kde.org/show_bug.cgi?id=312835
> 
> 
> Diffs
> -----
> 
> kwin/virtualdesktops.cpp ef3d25b 
> 
> Diff: http://git.reviewboard.kde.org/r/108253/diff/
> 
> 
> Testing
> -------
> 
> I would btw. have wished you happy research - took me a while back then to figure \
> /that/ crap. 
> 
> Thanks,
> 
> Thomas Lübking
> 
> 


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://git.reviewboard.kde.org/r/108253/">http://git.reviewboard.kde.org/r/108253/</a>
  </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On January 8th, 2013, 6:25 a.m., <b>Martin \
Gräßlin</b> wrote:</p>  <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">  <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">it should go into master, not 4.10.

Oh and it doesn&#39;t show that unit tests are pointless, it just shows that this had \
not been tested. Here&#39;s the test for it:


diff --git a/kwin/tests/test_virtual_desktops.cpp \
b/kwin/tests/test_virtual_desktops.cpp index 36e7933..52a93e0 100644
--- a/kwin/tests/test_virtual_desktops.cpp
+++ b/kwin/tests/test_virtual_desktops.cpp
@@ -287,6 +287,7 @@ void TestVirtualDesktops::testDirection(const QString \
&amp;actionName)  vds-&gt;initShortcuts(keys.data());
     QAction *action = keys-&gt;action(actionName);
     QVERIFY(action);
+    QVERIFY(static_cast&lt;KAction*&gt;(action)-&gt;isGlobalShortcutEnabled());
     action-&gt;trigger();
     QCOMPARE(vds-&gt;current(), result);
     QCOMPARE(functor(initCurrent, wrap), result);
@@ -571,6 +572,7 @@ void TestVirtualDesktops::switchToShortcuts()
         const QString desktop(toDesktop.arg(i));
         QAction *action = keys-&gt;action(desktop);
         QVERIFY2(action, desktop.toUtf8().constData());
+        QVERIFY(static_cast&lt;KAction*&gt;(action)-&gt;isGlobalShortcutEnabled());
         action-&gt;trigger();
         QCOMPARE(vds-&gt;current(), i);
     }
</pre>
 </blockquote>




 <p>On January 8th, 2013, 7:24 a.m., <b>Thomas Lübking</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Sorry, mechanically \
entered 4.10.

-- OT --

Actually that&#39;s what i meant - you don&#39;t test whether the code works, but \
whether your test works. The more complex the tested modules input becomes, the less \
reliable such test will be (action-&gt;trigger() works, but has nothing to do with \
the intended usage - your fix extends the test by an unrelated feature)

I don&#39;t actually query the unittesting in general to eg. figure whether a \
function does calculate / return correctly.</pre>  </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">yes from that \
perspective you are of course right.</pre> <br />








<p>- Martin</p>


<br />
<p>On January 8th, 2013, 7:24 a.m., Thomas Lübking wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://git.reviewboard.kde.org/media/rb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for kwin and Martin Gräßlin.</div>
<div>By Thomas Lübking.</div>


<p style="color: grey;"><i>Updated Jan. 8, 2013, 7:24 a.m.</i></p>






<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">and it will absolutely end up in the git history by this description \
=P</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">I would btw. have wished you happy research - took me a while back then \
to figure /that/ crap.</pre>  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="http://bugs.kde.org/show_bug.cgi?id=312835">312835</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>kwin/virtualdesktops.cpp <span style="color: grey">(ef3d25b)</span></li>

</ul>

<p><a href="http://git.reviewboard.kde.org/r/108253/diff/" style="margin-left: \
3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin


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

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