Re: Fail Tests on write to System.out

"Andreas Worm [email protected] [junit]" <[email protected]> Fri, 23 Oct 2015 11:16:35 +0200
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
--------------010507020805020303010702
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

The policeman-tools  were recommended in the Stackoverflow questions 
too. I may find time to try them out next week. If they don't prove 
useful, I will use TestRules. Again thanks for all the answers and 
especially thanks Dawid for sharing his TestRule.

Regards
Andreas

On 22/10/15 18:48, Dawid Weiss [email protected] [junit] wrote:
>
>     limiting the amount of output to a configurable number of bytes is
>     pretty cool but as you
>
>
> We didn't look for the coolness factor here, actually. In practice 
> it's fairly typical that developers will want to sysout stuff for 
> debugging (in tests). This is fine, unless the sysouts are huge, in 
> which case this takes resources (the runner spills outputs to disk, 
> because there are multiple parallel JVMs, etc.) and time. Hence the 
> "soft limit".
>
> As for preventing System.out calls in your production code (I suspect 
> you wish to enforce loggers or some other kind of infrastructure), 
> take a look at Uwe Schindler's forbidden-APIs tool, which parses 
> bytecode and can fail the build if an unwanted API is called. This is 
> very useful because you can apply this selectively, suppress inside 
> code, etc.
>
> https://github.com/policeman-tools/forbidden-apis/
>
> Dawid
>
> 

-- 
"Shhh.... I'm charging my laser."

    // Andreas Worm - headissue GmbH - Germany
  \//  https://headissue.com


--------------010507020805020303010702
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit





<head>

<style type="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 
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none; 
       }

       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>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">


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

<br><br>

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



    The policeman-tools  were recommended in the Stackoverflow questions
    too. I may find time to try them out next week. If they don't prove
    useful, I will use TestRules. Again thanks for all the answers and
    especially thanks Dawid for sharing his TestRule.<br>
    <br>
    Regards<br>
    Andreas<br>
    <br>
    <div class="moz-cite-prefix">On 22/10/15 18:48, Dawid Weiss
      <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a> [junit] wrote:<br>
    </div>
    <blockquote
cite="mid:CAM21Rt906JtKCmJhwkj0-5hHUFSi1Uob6758QKKPF7V=yj1hBw@mail.gmail.com"
      type="cite"> <span style="display:none"> </span>
      
          <div id="ygrp-text">
            <div dir="ltr">
              <div class="gmail_extra">
                <div class="gmail_quote">
                  <div> <br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px
                    0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;">
                    <div style="background-color:rgb(255,255,255);">
                      <div>
                        <div>
                          <div> limiting the amount of output to a
                            configurable number of bytes is pretty cool
                            but as you </div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>We didn't look for the coolness factor here,
                    actually. In practice it's fairly typical that
                    developers will want to sysout stuff for debugging
                    (in tests). This is fine, unless the sysouts are
                    huge, in which case this takes resources (the runner
                    spills outputs to disk, because there are multiple
                    parallel JVMs, etc.) and time. Hence the "soft
                    limit".</div>
                  <div><br>
                  </div>
                  <div>As for preventing System.out calls in your
                    production code (I suspect you wish to enforce
                    loggers or some other kind of infrastructure), take
                    a look at Uwe Schindler's forbidden-APIs tool, which
                    parses bytecode and can fail the build if an
                    unwanted API is called. This is very useful because
                    you can apply this selectively, suppress inside
                    code, etc.</div>
                  <div><br>
                  </div>
                  <div><a moz-do-not-send="true"
                      href="https://github.com/policeman-tools/forbidden-apis/">https://github.com/policeman-tools/forbidden-apis/</a><br>
                  </div>
                  <div><br>
                  </div>
                  <div>Dawid</div>
                  <div><br>
                  </div>
                </div>
              </div>
            </div>
          </div>
          
      
      <!-- end group email -->
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
"Shhh.... I'm charging my laser."

   // Andreas Worm - headissue GmbH - Germany
 \//  <a class="moz-txt-link-freetext" href="https://headissue.com">https://headissue.com</a></pre>
  



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

<br>


<br>

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


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

      
  

    
    <div id="fromDMARC" style="clear:both; margin-top: 10px;">
         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
         Posted by: Andreas Worm &lt;[email protected]&gt;         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
    </div>
<!-- Start Recommendations -->
<!-- End Recommendations -->



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

  <img src="http://geo.yahoo.com/serv?s=97476590/grpId=2423328/grpspId=1705006905/msgId=24720/stime=1445614473" width="1" height="1"> <br>

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

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

<br>



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

        <span id="vithd" style="font-weight: bold; color: #333; text-transform: uppercase; "><a href="https://groups.yahoo.com/neo/groups/junit/info;_ylc=X3oDMTJlMGw2bG0wBF9TAzk3MzU5NzE0BGdycElkAzI0MjMzMjgEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ0NTYxNDQ3Mw--" style="text-decoration: none;">Visit Your Group</a></span>

     <ul style="list-style-type: none; margin: 0; padding: 0; display: inline;">
            <li style="border-right: 1px solid #000; font-weight: 700; display: inline; padding: 0 5px; margin-left: 0;">
      <span class="cat"><a href="https://groups.yahoo.com/neo/groups/junit/members/all;_ylc=X3oDMTJmc2J0MWt1BF9TAzk3MzU5NzE0BGdycElkAzI0MjMzMjgEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0NDU2MTQ0NzM-" style="text-decoration: none;">New Members</a></span>
      <span class="ct" style="color: #ff7900;">2</span>
    </li>
                                              </ul>
  </div>


<div id="ft" style="font-family: Arial; font-size: 11px; margin-top: 5px; padding: 0 2px 0 0; clear: both;">
  <a href="https://groups.yahoo.com/neo;_ylc=X3oDMTJkdmgxODJkBF9TAzk3NDc2NTkwBGdycElkAzI0MjMzMjgEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDQ1NjE0NDcz" style="float: left;"><img src="http://l.yimg.com/ru/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height="15" width="137" alt="Yahoo! Groups" style="border: 0;"/></a>
  <div style="color: #747575; float: right;"> &bull; <a href="https://info.yahoo.com/privacy/us/yahoo/groups/details.html" style="text-decoration: none;">Privacy</a> &bull; <a href="mailto:[email protected]?subject=Unsubscribe" style="text-decoration: none;">Unsubscribe</a> &bull; <a href="https://info.yahoo.com/legal/us/yahoo/utos/terms/" style="text-decoration: none;">Terms of Use</a> </div>
</div>

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

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

   


  <br>

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


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

--------------010507020805020303010702--