<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pragmatic Programmer Issues - pietrowski.info &#187; testing</title>
	<atom:link href="http://pietrowski.info/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://pietrowski.info</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 07:31:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>skipfish &#8211; fast, easy and simple</title>
		<link>http://pietrowski.info/2010/04/skipfish-fast-easy-and-simple/</link>
		<comments>http://pietrowski.info/2010/04/skipfish-fast-easy-and-simple/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 18:30:53 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=255</guid>
		<description><![CDATA[Skipfish is google code project. It is web application security scanner, high speed (they claim 2000 requests per second* &#8211; * &#8211; at local LAN ) and due the fact it is command line tool without fancy wizards, options and so on, it is relatively easy to use, and for sure it is easy to [...]]]></description>
			<content:encoded><![CDATA[<p>Skipfish is google code project. It is web application security scanner, high speed (they claim 2000 requests per second* &#8211; * &#8211; at local LAN <img src='http://pietrowski.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) and due the fact it is command line tool without fancy wizards, options and so on, it is relatively easy to use, and for sure it is easy to just start scanning.</p>
<p>Skipfish is active scanner so it first scan application, preparing the map of web site, than recursively ran different test, the last thing is report generation. Documentation is simple and has a lot of example we can start on. So let&#8217;s see that in action.</p>
<p>One of such command is:
<p>
<em>$ skipfish  -m 5 -LVJ -W /dev/null -o output_dir -b ie http://www.example.com/</em></p>
<p>During the scan, Skipfish is displaying statistics:</p>
<pre>
Scan statistics
---------------

       Scan time : 0:11:07.0068
   HTTP requests : 2446 sent (3.71/s), 16228.73 kB in, 659.18 kB out (25.32 kB/s)
     Compression : 0.00 kB in, 0.00 kB out (0.00% gain)
 HTTP exceptions : 34 net errors, 0 proto errors, 0 retried, 0 drops
 TCP connections : 2451 total (1.09 req/conn)
  TCP exceptions : 0 failures, 1 timeouts, 0 purged
  External links : 745 skipped
    Reqs pending : 219        

Database statistics
-------------------

          Pivots : 471 total, 94 done (19.96%)
     In progress : 323 pending, 38 init, 12 attacks, 4 dict
   Missing nodes : 54 spotted
      Node types : 1 serv, 269 dir, 46 file, 1 pinfo, 91 unkn, 63 par, 0 val
    Issues found : 70 info, 111 warn, 49 low, 1 medium, 13 high impact
       Dict size : 0 words (0 new), 0 extensions, 0 candidates
</pre>
<p>After few hours/minutes, it depends on the site we are scanning, we will got</p>
<pre>
[+] Copying static resources...
[+] Sorting and annotating crawl nodes: 1666
[+] Looking for duplicate entries: 1666
[+] Counting unique issues: 1158
[+] Writing scan description...
[+] Counting unique issues: 1666
[+] Generating summary views...
[+] Report saved to outputDir/index.html
[+] This was a great day for science!
</pre>
</p>
<p>The report consist of &#8220;crawl results&#8221;, &#8220;document type overview&#8221; and &#8220;issue type overview&#8221;. My last scan result has some finding, but also has a lot of false positives, it seams that a lot of work still waiting for a Skipfish team, but it looks promising.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2010/04/skipfish-fast-easy-and-simple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RunWith helps JUnit</title>
		<link>http://pietrowski.info/2008/08/runwith-helps-junit/</link>
		<comments>http://pietrowski.info/2008/08/runwith-helps-junit/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 21:22:58 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[n n]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=98</guid>
		<description><![CDATA[When we want to test with Junit4 we can spot some problems. Firstly I thought that this is a maven-surefire-plugin problem, but as I dig into, the problem shows in JUnit runner. We track this problem on simple example. We create simple project. $ mvn archetype:generate We move to the project and we run test [...]]]></description>
			<content:encoded><![CDATA[<p>When we want to test with Junit4 we can spot some problems. Firstly I thought that this is a maven-surefire-plugin problem, but as I dig into, the problem shows in JUnit runner. We track this problem on simple example.</p>
<p>We create simple project.</p>
<pre>$ mvn archetype:generate</pre>
<p>We move to the project and we run test &#8211; everything is ok.</p>
<pre>$ mvn test
...
[INFO] BUILD SUCCESSFUL</pre>
<p>Now we change JUnit version in pom.xml from 3.8.1 to 4.4. We run test again and still everything is ok.<br />
We continue by adding java 5 target compilation.</p>
<pre>&lt;build&gt;
	&lt;plugins&gt;
	 &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;configuration&gt;
                &lt;source&gt;1.5&lt;/source&gt;
                &lt;target&gt;1.5&lt;/target&gt;
                &lt;encoding&gt;UTF-8&lt;/encoding&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;
	&lt;/plugins&gt;
&lt;/build&gt;</pre>
<p>Next we change testApp() method to something like this (JUnit4)</p>
<pre>    /**
     * Rigorous Test <img src='http://pietrowski.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
     */
    @Test
    public void tapp()   {
        assertTrue( true );
    }</pre>
<p>Test fails !!!. The stacktrace is :</p>
<pre>-------------------------------------------------------------------------------
Test set: info.pietrowski.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.036 sec &lt;&lt;&lt; FAILURE!
warning(junit.framework.TestSuite$1)  Time elapsed: 0.008 sec  &lt;&lt;&lt; FAILURE!
junit.framework.AssertionFailedError: No tests found in info.pietrowski.AppTest
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.TestSuite$1.runTest(TestSuite.java:97)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)</pre>
<p>No tests found !!!. What&#8217;s going on. The core thread-dump lines are:</p>
<pre> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
 at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)</pre>
<p>This means that maven-surefire-plugin run <strong>Junit4TestSet</strong> as it should do, but unfortunately JUnit runs <strong>Junit38ClassRunner</strong> !!!. This strange behavior is due we still extends <strong>TestCase</strong> class. So the quickies solution is to drop this extend. We can not use now assert* methods, the solution is to static import <em><strong>org.junit.Assert.*</strong></em>. Everything backs to normal.</p>
<p>But what if we want to extend <strong>TestCase</strong> (DBUnit, Spring*TestCase). In case of Spring test classes there is special tree for JUnit4 and TestNG so every TestCase class has equivalent in JUnit4 and TestNG. So for example <strong>AbstractTransactionalJUnit38SpringContextTests</strong>, has equivalents <strong>AbstractTransactionalJUnit4SpringContextTests</strong>, and <strong>AbstractTransactionalTestNGSpringContextTests</strong>.</p>
<p>The problem still exists when library does not provide such equivalents. Let&#8217;s look to the code, the problematic function is</p>
<p><a href="http://pietrowski.info/wp-content/uploads/2008/08/obrazek-3.png"><img class="alignnone size-full wp-image-100" title="problematic method" src="http://pietrowski.info/wp-content/uploads/2008/08/obrazek-3.png" alt="" width="500" height="183" /></a></p>
<p>The procedure is simple, if  class has <strong>@Ignore</strong> annotation than we skip this class, next we look if  class has <strong>@RunWith</strong> annotation if so we get value of this annotation (we talk about it later). Next three is simple if  class has suite method we run Suite runner called <strong>AllTest</strong>, if  class is subclass of <strong>TestCase</strong> then we use <strong>JUnit38ClassRunner</strong> if everything else  we run with <strong>JUnit4ClassRunner</strong>. We solved the mystery <img src='http://pietrowski.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Our only hope is <strong>@RunWith </strong>annotation, we can use it with <strong>JUnit4ClassRunner</strong> and than everything is alright.</p>
<p><a href="http://pietrowski.info/wp-content/uploads/2008/08/obrazek-1.png"><img class="alignnone size-full wp-image-99" title="our program" src="http://pietrowski.info/wp-content/uploads/2008/08/obrazek-1.png" alt="" width="462" height="291" /></a></p>
<p>Of course we can use this annotation with any class that extends <strong>Runner</strong>. I hope this solves your problems. See you.</p>
<p>Pedro</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2008/08/runwith-helps-junit/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
