Note that there are some explanatory texts on larger screens.

plurals
  1. POexternalizing junit stub objects
    text
    copied!<p>In my project we created stub files for testing junits in java(factories) itself. However, we have to externalize these stubs. After seeing a number of serializers/deserializers, we settled on using XStream to serialize and deserialize these stub objects. <a href="http://xstream.codehaus.org/" rel="nofollow noreferrer">XStream</a> works like a charm. Its pretty good at what it claims to be. Previously, we had a single factory class say AFactory which produced all the stubs needed for testing different test cases. Now when externalizing each of the stub generated, we hit a road block. We had to create 1 xml file for each stub produced by the factory.<br/> For example,</p> <pre><code>public final class AFactory{ public static A createStub1(){ /*Code here */} public static A createStub2(){ /*Code here */} public static A createStub3(){ /*Code here */} } </code></pre> <p>Now, when trying to move this stubs to external files, we had to create 1 xml file for each stub created(A-stub1.xml, A-stub2.xml and A-stub3.xml). The problem with this approach is that, it leads to proliferation of xml stub files.<br/></p> <p>I was thinking, how about keeping all the stubs related to a single bean class in a single xml file.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;stubs class="A"&gt; &lt;stub id="stub1"&gt; &lt;!-- Here comes the externalized xml stub representation --&gt; &lt;/stub&gt; &lt;stub id="stub2"&gt; &lt;/stub&gt; &lt;/stubs&gt; </code></pre> <p>Is there a framework which allows you keep all the stub in xml representation in a single xml file as above ? Or What do you guys suggest should be the right approach to adhere to ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload