felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Felix > Sigil JUnit
Date Wed, 16 Sep 2009 13:12:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=FELIX&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/FELIX/Sigil+JUnit">Sigil
JUnit</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~dsavage@apache.org">David
Savage</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="SigilJUnit-Overview"></a>Overview</h2>

<p>The Sigil JUnit plugin is an OSGi bundle that when started in an OSGi enabled JVM
watches for other bundles that contain JUnit TestCase classes in the framework. The main access
point to the plugin is the <tt>org.cauldron.sigil.junit.server.JUnitService</tt>.</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>JUnitService.java</b></div><div
class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">package</span> org.cauldron.sigil.junit.server;

<span class="code-keyword">import</span> java.util.Set;

<span class="code-keyword">import</span> org.osgi.framework.BundleContext;

<span class="code-keyword">import</span> junit.framework.TestSuite;

/**
 *
 */	
<span class="code-keyword">public</span> <span class="code-keyword">interface</span>
JUnitService {
	/**
	 * Returns the names of all tests currently installed in the OSGi runtime
	 */	
	Set&lt;<span class="code-object">String</span>&gt; getTests();

	/**
	 * Create a <span class="code-keyword">new</span> instance of the specified test.
Equivalent to calling createTest(test, <span class="code-keyword">null</span>);
	 */	
	TestSuite createTest(<span class="code-object">String</span> test);
	
	/**
	 * Create a <span class="code-keyword">new</span> instance of the specified test
passing the specified bundle context to the test classes.
	 * If ctx is <span class="code-keyword">null</span> the callers BundleContext
is passed to the test.
	 */	
	TestSuite createTest(<span class="code-object">String</span> test, BundleContext
ctx);
}
</pre>
</div></div>

<p>When a test is created the <tt>JUnitService</tt> introspects the test
class and looks for a method <tt>public void setBundleContext(BundleContext ctx);</tt>
if one is found then the BundleContext is injected into the test class before being returned
to the caller. </p>

<h2><a name="SigilJUnit-CLI"></a>CLI</h2>

<p>For convenience we provide a simple newton command line interface to the JUnit plugin
in the bundle <tt>org.cauldron.sigil.junit.cli</tt>. This allows the user to find
and run tests currently installed in the container.</p>

<p>examples:</p>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>List
Tests</b></div><div class="codeContent panelContent">
<pre class="code-java">
junit
	org.cauldron.sigil.junit.example.Test1
	org.cauldron.sigil.junit.example.Test10
	org.cauldron.sigil.junit.example.Test2
	org.cauldron.sigil.junit.example.Test3
	org.cauldron.sigil.junit.example.Test4
	org.cauldron.sigil.junit.example.Test5
	org.cauldron.sigil.junit.example.Test6
	org.cauldron.sigil.junit.example.Test7
	org.cauldron.sigil.junit.example.Test8
	org.cauldron.sigil.junit.example.Test9
</pre>
</div></div>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Run
a test</b></div><div class="codeContent panelContent">
<pre class="code-java">
&gt; junit org.cauldron.sigil.junit.example.Test1
Start testSuccess(org.cauldron.sigil.junit.example.Test1)
End testSuccess(org.cauldron.sigil.junit.example.Test1)
Start testFail(org.cauldron.sigil.junit.example.Test1)
Failure testFail(org.cauldron.sigil.junit.example.Test1): Failed
End testFail(org.cauldron.sigil.junit.example.Test1)
Ran 2 tests. 1 failures 0 errors.
</pre>
</div></div>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Run
a test (quietly)</b></div><div class="codeContent panelContent">
<pre class="code-java">
&gt; junit -q org.cauldron.sigil.junit.example.Test1
Ran 2 tests. 1 failures 0 errors.
</pre>
</div></div>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Run
all tests (quietly)</b></div><div class="codeContent panelContent">
<pre class="code-java">
&gt; junit -q *
Ran 20 tests. 10 failures 0 errors.
</pre>
</div></div>

<div class="code panel" style="border-style: solid;border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Run
all tests (quietly and write results to specified directory)</b></div><div
class="codeContent panelContent">
<pre class="code-java">
&gt; junit -q -d /tmp *
Writing results to /tmp
Ran 20 tests. 10 failures 0 errors.
</pre>
</div></div>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/FELIX/Sigil+JUnit">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=2326674&revisedVersion=2&originalVersion=1">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/FELIX/Sigil+JUnit?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message