cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bigbluebeetle
Level 2

Unit testing of InstallAnywhere custom code ( JUnit or others )

Hello

We have a number of custom code classes that we use for checking various prerequisites that are part of our installer. Currently, it's very tedious testing minor changes to this code since it involves repeated builds and runs of the complete installer to test. Is there some documentation out there that explains how the custom code can be unit-tested using JUnit or some other testing framework?

I was able to include all the java classes we use in a project and write some simple test cases that execute some of the code. Anything that uses the InstallerProxy class, however, does not work, and it appears that I'm not setting up the InstallerProxy correctly to supply the correct context. Can anyone offer any more guidance on this?

Thank you
Arjun
Labels (1)
0 Kudos
(1) Reply
mjspka
Level 3

Here is the sample code that I am using.....Best of luck

@Test
public void testPerformActionDuringInstall() throws InstallException, ConfigurationException {

CustomCodeAction customCodeAction = new CustomCodeAction();

final InstallerProxy ipMock = mock(InstallerProxy.class);

final HashMap testProperties = new HashMap();
testProperties.put("$PRODUCT_VERSION_NUMBER$", "1.0.0");

doAnswer(new Answer() {
public Object answer(InvocationOnMock invocation) {
Object[] args = invocation.getArguments();
return testProperties.get((String)args[0]);
}
}).when(ipMock).substitute(anyString());

customCodeAction.install(ipMock);

---
---
do the asserts...
---
---
}
0 Kudos