Does anyone have idea about writing unit test case for ATG using Mockito? I came across following discussions while goggling - Automated unit tests for ATG development and Using PowerMock to obtain the ATG Nucleus in testing results in NPE
But need a help in setting up Nucleus and other dependencies (DAS, DPS, DSS etc.) and a sample test class for droplet using Mockito.
We are using ATG Dust where we have to set all the dependencies. I am wondering if we can replace ATG Dust completely with Mockito. Here is the example how we are writing the test cases -
- A Base class for setting Nucleus -
package com.ebiz.market.support; import java.io.File; import java.util.Arrays; import atg.nucleus.NucleusTestUtils; import atg.test.AtgDustCase; import atg.test.util.FileUtil; public class BaseTestCase extends AtgDustCase { public atg.nucleus.Nucleus mNucleus = null; private final String ATGHOME="C://ATG/ATG9.4//home"; private final String ATGHOMEPROPERTY = "atg.dynamo.home"; protected void setUp() throws Exception { super.setUp(); String dynamoHome = System.getProperty(ATGHOMEPROPERTY); if(dynamoHome == null) System.setProperty(ATGHOMEPROPERTY, ATGHOME); File configpath = NucleusTestUtils.getConfigpath(this.getClass(), this.getClass().getName(), true); FileUtil.copyDirectory("src/test/resources/config/test/", configpath.getAbsolutePath(), Arrays.asList(new String [] {".svn"})); copyConfigurationFiles(new String[]{"config"}, configpath.getAbsolutePath(), ".svn"); } public File getConfigPath() { return NucleusTestUtils.getConfigpath(this.getClass(), this.getClass().getName(), true); } }
- Writing the test case by extending the base class -
public class BizDropletTest extends BaseTestCase { private BizDroplet bizDroplet; @Before public void setUp() throws Exception { super.setUp(); mNucleus = NucleusTestUtils.startNucleusWithModules(new String[] { "DSS", "DPS", "DAFEAR" }, this.getClass(), this.getClass().getName(), "com/ebiz/market/support/droplet/BizDroplet"); autoSuggestDroplet = (AutoSuggestDroplet) mNucleus.resolveName("com/ebiz/market/support/droplet/BizDroplet"); try { bizDroplet.doStartService(); } catch (ServiceException e) { fail(e.getMessage()); } } /** Other methods */ }
So, how Mockito can handle these? Again, for me the target is to replace ATG Dust with Mockito completely because ATG Dust take lot of time in running tests due to huge dependencies.
Thanks.