Good job with the unit testing Benjamin. OJ could definitely use more
unit testing!

Landon

On Fri, Jan 13, 2012 at 4:16 AM, Benjamin Gudehus
<hasteb...@googlemail.com> wrote:
> Hi!
>
> I've committed the first unit test for a plugin at revision 2614.
> org.openjump.core.ui.plugin.tools.UnionByAttributePlugInTest
>
> There is only one single test case, but more will follow.
> Since I really like to practicise behaviour-driven development (BDD),
> I've tried to adapt given-when-then like scenarios via comments.
>
> Here is a small snipped of code to get an impression on how a
> test case looks:
>
> @Test
> public void testAddedResultLayer() throws Exception {
>     // given: "a loaded shapefile fixture"
>     File fixture = new File("src/fixtures/dissolve.jml");
>     TestTools.openFile(fixture, workbench.getContext());
>
>     // and: "plugin with dialog values"
>     PlugIn plugin = new UnionByAttributePlugIn();
>     LayerManager layerManager = workbench.getContext().getLayerManager();
>     HashMap<String, Object> parameters = new HashMap<String, Object>();
>     parameters.put("layer", layerManager.getLayer("dissolve"));
>     parameters.put("use_attribute", true);
>     parameters.put("attribute", "LABEL");
>     parameters.put("ignore_empty", false);
>     parameters.put("merge_linestrings", false);
>     parameters.put("aggregate_unused_fields", false);
>     TestTools.configurePlugIn(plugin, parameters);
>
>     // when: "union by attribute is called"
>     TestTools.executePlugIn(plugin, workbench.getContext());
>
>     // then: "layer manager contains the source and result layer"
>     assertEquals(2, layerManager.getLayers().size());
>     //Thread.sleep(Integer.MAX_VALUE);
> }
>
> How to run a test:
> 1. Open UnionByAttributePlugInTest in Eclipse (CTRL+SHIFT+T helps)
> 2. Menubar: Run > Run As > JUnit Test
> (/lib/junit.jar must be in the classpath)
>
> Greetings
> Benjamin
>
> P.S.:
> Some of the concepts of BDD are described practically in [1].
> The description is from the documentation for Spock, an
> specification framework for the programming language Groovy.
> [1] http://code.google.com/p/spock/wiki/SpockBasics
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Mar 27 - Feb 2
> Save $400 by Jan. 27
> Register now!
> http://p.sf.net/sfu/rsa-sfdev2dev2
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to