Category Archives: Test

Unit Test – Using PowerMock with FileNet

To write true unit test, and make sure your FileNet developments do not rely on FileNet for unit test, one solution is using PowerMock, because it allows to mock the static methods from FileNet, that we are using a lot since there are quite usual in the FileNet Java API, for example all the fetInstance and getInstance of the Factory objects, when creating Batches and so on.

How to set up PowerMock for your project

If you are not using any project management software to manage your dependencies like Maven, you’ll have to download the PowerMockito dependencies on the PowerMock website.

PowerMockito can work with both Mockito and EasyMock, you can use which one you are familiar with. If you are not familiar with any of them, I would recommend Mockito.  I prefer the Mockito syntax, I think it makes test easier to understand and maintain. You only have to take the zip for what you want to do, in our case the  powermock-mockito-junit zip.

Then add all zip to your classpath and you are good to go.
Continue reading

Unit Testing and FileNet

Unit test has to keep its unit, even with FileNet

In Unit Test, there is Unit, and people tends to forget that when writing tests with FileNet. That means your test should not rely on anything else than itself, especially not FileNet. Because then what happens? Your tests fail because the platform is down, the test user credentials changed or a network error occurred, and after a while you’ stop noticing the error, thinking “that’s the platform again, but the method’s fine”, or worst, you end up disabling test on your build, because they are becoming a liability more than a help.

Well, this is not how unit test work, I guess you already know that but still. A unit test has to be perfectly reliable, that’s means if your method produce the right outcome, the test should always pass, no matter what, if the test fail, there is something wrong with the method, and you MUST take a look at what’s wrong, not ignore the failure. If you write true unit test, this should be true and you can enable test in the build, and trust failures as real defects.

I’ll write in another post how to set up PowerMock, and some examples so this one does not become to long.

How to make FileNet development not rely on FileNet

Continue reading