Hunsu
Hunsu

Reputation: 3381

How to unit test Eclipse plugin?

I want to improve the Builder Pattern Eclipse Plugin. I want to change the code generated to support generics class and include the class name in the builder class name.

I located where I must add my changes. I want to use TDD but I'm stuck as I don't know how to create an ICompilationUnit type. I want to create an ICompilationUnitfrom test file and then compare the result to what I expect. I know I can mock it but I don't know well the interface and what each method should do.

I didn't find resources to solve my problem. The resources I found are about GUI testing.

Upvotes: 0

Views: 618

Answers (1)

Zoltán Ujhelyi
Zoltán Ujhelyi

Reputation: 13858

Sadly, the ICompilationUnit defined by JDT is not a simple class, so if you want to unit test it, either you have to mock it (and thus understand what is expected), or you have to use JDT to parse it. For basics, you can use the vogella.com JDT tutorial.

Furthermore, I would look into the test suite of JDT itself, as there were similar issues solved already.

Upvotes: 2

Related Questions