Re: EgTest: quick & easy unit tests

"Kevin Cooney [email protected] [junit]" <[email protected]> Thu, 30 Mar 2017 14:08:51 -0700
Newsgroups gmane.comp.java.junit.user
Message-ID <CAA3E+eXgMGpepy+8=xZoEPXf0fy5JhjByYZX1uu7Xa_ney-Jkw@mail.gmail.com>
--94eb2c0568026a706c054bf91b12
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

For an example of what Russ is talking about, see Testable Examples in Go:
https://blog.golang.org/examples

-- Kevin

On Thu, Mar 30, 2017 at 1:23 PM, Russell Gold [email protected] [junit] <
[email protected]> wrote:

>
>
> This is at least an intriguing idea, although I really hate the idea of
> giving programmers another excuse for not writing full-on unit tests, or
> developing test-first.  Do you have examples of what this looks like in t=
he
> Javadoc? That seems as though it would be a great use for it. That is,
> rather than making unit testing =E2=80=9Cexcuse-free,=E2=80=9D as you say=
, it would have
> the *primary* intent of adding examples to Javadoc, while verifying that
> those examples actually work. I know that I have run into problems that w=
ay
> - I=E2=80=99ve written examples, only to have developers ask me for help =
because
> there was a typo in my documentation.
>
> - Russ
>
> -----------------
> Author, Getting Started with Apache Maven <http://www.packtpub.com/
> getting-started-with-apache-maven/video>
> Author, HttpUnit <http://www.httpunit.org> and SimpleStub <
> http://simplestub.meterware.com>
> Now blogging at <http://agilementor.us/blog/>
>
> Have you listened to Edict Zero <https://edictzero.wordpress.com>? If
> not, you don=E2=80=99t know what you=E2=80=99re missing!
>
> On Mar 10, 2017, at 6:29 PM, David Leppik [email protected] [junit] <
> [email protected]> wrote:
>
> I have a new framework which combines unit tests and documentation in
> source code. The goal is to make unit testing "excuse-free:" i.e. so simp=
le
> that they become the lazy way to spot-check code, while ensuring that
> examples in Javadoc are automatically tested.
>
>
> This is a complementary way to write certain simple tests, rather than a
> full-on replacement for hand-writing JUnit tests.
>
>
>
>
> https://github.com/dleppik/EgTest
>
>
>
>
> A quick example; this would be found in a main (non-test) Java file:
>
>
> @Eg(given =3D {"1", "2"}, returns =3D "3")
> @Eg(given =3D {"1", "Integer.MAX_VALUE"}, returns =3D "Integer.MIN_VALUE"=
)
> static int add(int a, int b) {
>    return a + b;
> }
>
>
> The above annotations show up in Javadoc and they produce a JUnit test
> which tests the assertions on the add method.
>
>
> Any feedback would be extremely welcome. This is early enough that it's
> not too late to change the syntax or nomenclature if there's a better way
> to go about it.
>
>
>
>
> -Dave
>
>
> --
> David Leppik                                     http://www.leppik.net/
> david/blog/
> [email protected]
>
>
> "As a computer shrinks, the gravitational force that its components exert
> on one another becomes stronger and eventually grows so intense that no
> material object can escape."
> -- Scientific American, Nov 2004, p. 56
>
>
>
>
> ------------------------------------
> Posted by: David Leppik <[email protected]>
> ------------------------------------
>
>
> ------------------------------------
>
> Yahoo Groups Links
>
>
>
>
>=20
>

--94eb2c0568026a706c054bf91b12
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable





<head>

<style type=3D"text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title=20
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none;=20
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html>
<head>
<style type=3D"text/css">
<!--
#ygrp-mkp {
  border: 1px solid #d8d8d8;
  font-family: Arial;
  margin: 10px 0;
  padding: 0 10px;
}

#ygrp-mkp hr {
  border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
  color: #628c2a;
  font-size: 85%;
  font-weight: 700;
  line-height: 122%;
  margin: 10px 0;
}

#ygrp-mkp #ads {
  margin-bottom: 10px;
}

#ygrp-mkp .ad {
  padding: 0 0;
}

#ygrp-mkp .ad p {
  margin: 0;
}

#ygrp-mkp .ad a {
  color: #0000ff;
  text-decoration: none;
}
-->
</style>
</head>
<body>



<!-- |**|begin egp html banner|**| -->

<br><br>

<!-- |**|end egp html banner|**| -->


<div dir=3D"ltr">For an example of what Russ is talking about, see Testable=
 Examples in Go:=C2=A0<a href=3D"https://blog.golang.org/examples">https://=
blog.golang.org/examples</a><div class=3D"gmail_extra"><br></div><div class=
=3D"gmail_extra">-- Kevin</div><div class=3D"gmail_extra"><br><div class=3D=
"gmail_quote">On Thu, Mar 30, 2017 at 1:23 PM, Russell Gold <a href=3D"mail=
to:[email protected]">[email protected]</a> [junit] <span dir=3D"ltr">&lt=
;<a href=3D"mailto:[email protected]" target=3D"_blank" class=3D"cremed=
">[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex">


<u></u>









=20
<div style=3D"background-color:#fff">
<span style=3D"display:none">=C2=A0</span>


<div id=3D"m_8012712246283953487ygrp-mlmsg">
  <div id=3D"m_8012712246283953487ygrp-msg">


    <div id=3D"m_8012712246283953487ygrp-text">
=20=20=20=20=20=20
=20=20=20=20=20=20
      <p>This is at least an intriguing idea, although I really hate the id=
ea of giving programmers another excuse for not writing full-on unit tests,=
 or developing test-first.=C2=A0 Do you have examples of what this looks li=
ke in the Javadoc? That seems as though it would be a great use for it. Tha=
t is, rather than making unit testing =E2=80=9Cexcuse-free,=E2=80=9D as you=
 say, it would have the <i>primary</i> intent of adding examples to Javadoc=
, while verifying that those examples actually work. I know that I have run=
 into problems that way - I=E2=80=99ve written examples, only to have devel=
opers ask me for help because there was a typo in my documentation.=C2=A0</=
p><div><br></div><div>- Russ<br><div><br></div><div><div>-----------------<=
/div><div>Author,=C2=A0Getting Started with Apache Maven &lt;<a href=3D"htt=
p://www.packtpub.com/getting-started-with-apache-maven/video" target=3D"_bl=
ank" class=3D"cremed">http://www.packtpub.com/<wbr>getting-started-with-apa=
che-<wbr>maven/video</a>&gt;</div><div>Author, HttpUnit &lt;<a href=3D"http=
://www.httpunit.org" target=3D"_blank" class=3D"cremed">http://www.httpunit=
.org</a>&gt; and SimpleStub &lt;<a href=3D"http://simplestub.meterware.com"=
 target=3D"_blank" class=3D"cremed">http://simplestub.meterware.<wbr>com</a=
>&gt;</div><div>Now blogging at &lt;<a href=3D"http://agilementor.us/blog/"=
 target=3D"_blank" class=3D"cremed">http://agilementor.us/blog/</a>&gt;<br>=
<br></div><div>Have you listened to Edict Zero &lt;<a href=3D"https://edict=
zero.wordpress.com" target=3D"_blank" class=3D"cremed">https://edictzero.wo=
rdpress.<wbr>com</a>&gt;? If not, you don=E2=80=99t know what you=E2=80=99r=
e missing!</div><div><br></div><div><blockquote type=3D"cite"><span class=
=3D""><div>On Mar 10, 2017, at 6:29 PM, David Leppik <a href=3D"mailto:davi=
[email protected]" target=3D"_blank" class=3D"cremed">[email protected]</a> [juni=
t] &lt;<a href=3D"mailto:[email protected]" target=3D"_blank" class=3D"=
cremed">[email protected]</a>&gt; wrote:</div><br class=3D"m_8012712246=
283953487Apple-interchange-newline"></span><div><div><span class=3D"">I hav=
e a new framework which combines unit tests and documentation in source cod=
e. The goal is to make unit testing &quot;excuse-free:&quot; i.e. so simple=
 that they become the lazy way to spot-check code, while ensuring that exam=
ples in Javadoc are automatically tested.<br><br><br>This is a complementar=
y way to write certain simple tests, rather than a full-on replacement for =
hand-writing JUnit tests.<br><br><br><br><br><a href=3D"https://github.com/=
dleppik/EgTest" target=3D"_blank" class=3D"cremed">https://github.com/dlepp=
ik/<wbr>EgTest</a><br><br><br><br><br>A quick example; this would be found =
in a main (non-test) Java file:<br><br><br>@Eg(given =3D {&quot;1&quot;, &q=
uot;2&quot;}, returns =3D &quot;3&quot;)<br>@Eg(given =3D {&quot;1&quot;, &=
quot;Integer.MAX_VALUE&quot;}, returns =3D &quot;Integer.MIN_VALUE&quot;)<b=
r>static int add(int a, int b) {<br> =C2=A0=C2=A0=C2=A0return a + b;<br>}<b=
r><br><br>The above annotations show up in Javadoc and they produce a JUnit=
 test which tests the assertions on the add method.<br><br><br>Any feedback=
 would be extremely welcome. This is early enough that it&#39;s not too lat=
e to change the syntax or nomenclature if there&#39;s a better way to go ab=
out it.<br><br><br><br><br><span class=3D"m_8012712246283953487Apple-tab-sp=
an" style=3D"white-space:pre-wrap">	</span>-Dave<br><br><br>--<br>David Lep=
pik =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0<wbr>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0<a href=3D"http://www.leppik.net/david/blog/" target=3D"_blank" class=3D=
"cremed">http://www.leppik.net/<wbr>david/blog/</a><br>[email protected]<br>=
<br><br>&quot;As a computer shrinks, the gravitational force that its compo=
nents exert on one another becomes stronger and eventually grows so intense=
 that no material object can escape.&quot;<br>-- Scientific American, Nov 2=
004, p. 56<br><br><br><br><br></span>------------------------------<wbr>---=
---<span class=3D""><br>Posted by: David Leppik &lt;<a href=3D"mailto:david=
@leppik.net" target=3D"_blank" class=3D"cremed">[email protected]</a>&gt;<br=
></span>------------------------------<wbr>------<br><br><br>--------------=
----------------<wbr>------<br><br>Yahoo Groups Links<br><br>&lt;*&gt; To v=
isit your group on the web, go to:<br> =C2=A0=C2=A0=C2=A0<a href=3D"http://=
groups.yahoo.com/group/junit/" target=3D"_blank" class=3D"cremed">http://gr=
oups.yahoo.com/<wbr>group/junit/</a><br><br>&lt;*&gt; Your email settings:<=
br> =C2=A0=C2=A0=C2=A0Individual Email | Traditional<br><br>&lt;*&gt; To ch=
ange settings online go to:<br> =C2=A0=C2=A0=C2=A0<a href=3D"http://groups.=
yahoo.com/group/junit/join" target=3D"_blank" class=3D"cremed">http://group=
s.yahoo.com/<wbr>group/junit/join</a><br> =C2=A0=C2=A0=C2=A0(Yahoo! ID requ=
ired)<br><br>&lt;*&gt; To change settings via email:<br> =C2=A0=C2=A0=C2=A0=
<a href=3D"mailto:[email protected]" target=3D"_blank" class=3D"=
cremed">junit-digest@yahoogroups.<wbr>com</a> <br> =C2=A0=C2=A0=C2=A0<a hre=
f=3D"mailto:[email protected]" target=3D"_blank" class=3D"=
cremed">junit-fullfeatured@<wbr>yahoogroups.com</a><br><br>&lt;*&gt; To uns=
ubscribe from this group, send an email to:<br> =C2=A0=C2=A0=C2=A0<a href=
=3D"mailto:[email protected]" target=3D"_blank" class=3D"cr=
emed">junit-unsubscribe@<wbr>yahoogroups.com</a><br><br>&lt;*&gt; Your use =
of Yahoo Groups is subject to:<br> =C2=A0=C2=A0=C2=A0<a href=3D"https://inf=
o.yahoo.com/legal/us/yahoo/utos/terms/" target=3D"_blank" class=3D"cremed">=
https://info.yahoo.com/<wbr>legal/us/yahoo/utos/terms/</a><br><br></div></d=
iv></blockquote></div><br></div></div><p></p>

    </div>
=20=20=20=20=20

=20=20=20=20
    <div style=3D"color:#fff;height:0"></div>


</div>



=20=20






</blockquote></div><br></div></div>




<!-- |**|begin egp html banner|**| -->

<br>


<br>

<!-- |**|end egp html banner|**| -->


<div width=3D"1" style=3D"color: white; clear: both;"/>__._,_.___</div>

=20=20=20=20=20=20
=20=20

=20=20=20=20
    <div id=3D"fromDMARC" style=3D"clear:both; margin-top: 10px;">
         <hr style=3D"height:2px ; border-width:0; color:#E3E3E3; backgroun=
d-color:#E3E3E3;">
         Posted by: Kevin Cooney &lt;[email protected]&gt;         <hr sty=
le=3D"height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;=
">
    </div>
<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src=3D"http://geo.yahoo.com/serv?s=3D97476590/grpId=3D2423328/grpspI=
d=3D1705006905/msgId=3D24763/stime=3D1490909228" width=3D"1" height=3D"1"> =
<br>

<!-- |**|end egp html banner|**| -->

=20=20
<!-- |**|begin egp html banner|**| -->

<br>



=20=20=20
=20=20=20=20=20
=20
        <!-- |**|begin egp html banner|**| -->
        <div id=3D"ygrp-vital" style=3D"background-color: #f2f2f2; font-fam=
ily: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">

        <span id=3D"vithd" style=3D"font-weight: bold; color: #333; text-tr=
ansform: uppercase; "><a href=3D"https://groups.yahoo.com/neo/groups/junit/=
info;_ylc=3DX3oDMTJlcWdqMThiBF9TAzk3MzU5NzE0BGdycElkAzI0MjMzMjgEZ3Jwc3BJZAM=
xNzA1MDA2OTA1BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ5MDkwOTIyOA--" style=3D"tex=
t-decoration: none;">Visit Your Group</a></span>

     <ul style=3D"list-style-type: none; margin: 0; padding: 0; display: in=
line;">
            <li style=3D"border-right: 1px solid #000; font-weight: 700; di=
splay: inline; padding: 0 5px; margin-left: 0;">
      <span class=3D"cat"><a href=3D"https://groups.yahoo.com/neo/groups/ju=
nit/members/all;_ylc=3DX3oDMTJmdXJ2a2k4BF9TAzk3MzU5NzE0BGdycElkAzI0MjMzMjgE=
Z3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0OTA5MDkyMjg-" s=
tyle=3D"text-decoration: none;">New Members</a></span>
      <span class=3D"ct" style=3D"color: #ff7900;">1</span>
    </li>
                                              </ul>
  </div>


<div id=3D"ft" style=3D"font-family: Arial; font-size: 11px; margin-top: 5p=
x; padding: 0 2px 0 0; clear: both;">
  <a href=3D"https://groups.yahoo.com/neo;_ylc=3DX3oDMTJkZzFsM2ZhBF9TAzk3ND=
c2NTkwBGdycElkAzI0MjMzMjgEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA2dmcARzd=
GltZQMxNDkwOTA5MjI4" style=3D"float: left;"><img src=3D"http://l.yimg.com/r=
u/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height=3D"15"=
 width=3D"137" alt=3D"Yahoo! Groups" style=3D"border: 0;"/></a>
  <div style=3D"color: #747575; float: right;"> &bull; <a href=3D"https://i=
nfo.yahoo.com/privacy/us/yahoo/groups/details.html" style=3D"text-decoratio=
n: none;">Privacy</a> &bull; <a href=3D"mailto:junit-unsubscribe@yahoogroup=
s.com?subject=3DUnsubscribe" style=3D"text-decoration: none;">Unsubscribe</=
a> &bull; <a href=3D"https://info.yahoo.com/legal/us/yahoo/utos/terms/" sty=
le=3D"text-decoration: none;">Terms of Use</a> </div>
</div>

<!-- |**|end egp html banner|**| -->

  </div> <!-- ygrp-msg -->

=20=20=20


  <br>

<!-- |**|end egp html banner|**| -->


<div style=3D"color: white; clear: both;"/>__,_._,___</div>
</body>

</html>

--94eb2c0568026a706c054bf91b12--