|
|
|
|
Re: How to start unit testing [message #1739882 is a reply to message #1739860] |
Fri, 05 August 2016 10:46 |
Onno Kouwenberg Messages: 18 Registered: January 2015 |
Junior Member |
|
|
The first test I tried to create was the following:
@Test
public void emptyDocument() {
RecipePartitioner partitioner = new RecipePartitioner();
Document document = new Document("");
partitioner.connect(document);
assertSame(partitioner, document.getDocumentPartitioner());
}
Where the implementation code is:
@Override
public void connect(IDocument document) {
this.document = document;
document.setDocumentPartitioner(this);
}
This triggers the document class to start partitioning with a SafeRunnable, which requires more of the OSGi framework.
Of course I can use Mockito to mock the document class, in Gradle I'd simply add a testCompile dependency. In the current setup I can of course add a mockito dependency as optional, but it seems a rather wierd strategy. I'm sure there must be another way.
@Dirk, In my Felix based OSGi project I'm do JUnit testing in a fairly standard, and easy, way. A bundle has a compile dependency on a service api, and I use mockito to mock the service. As with the Gradle conventions source is in src/main/java, tests are in src/test/java. Only the src/main/java end up in the OSGi bundle. I expect Maven to have a similar mechanism.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05550 seconds