Tests and new API for Sonar IDE


Hi all,

This is my third post about Google Summer of Code 2010 with Sonar team. But before reporting about progress on GSoC, I’d like to share my happiness with you : now I’m a Master of Applied Mathematics and Informatics! It means that I can spend more time working on Sonar.

Let’s examine what was done for Sonar IDE in last week.

Testing

From my experience I know that it’s really nightmare – work on a big project without tests. Especially when we have a small team and when we don’t have people for regular testing. And I’m always afraid to change something, if this is not tested automatically. That’s why I’ve started work on creation of tests for Sonar IDE in early stage.

For now we are using Jetty ServletTester for emulation of Sonar server. And we have unit tests for core library used by all IDEs, but I’d like to have integration tests for different IDEs too.

So I’ve made a several integration tests for Eclipse Sonar Plugin : tests for UI – with help of SWTBot. This was a really simply, but I still don’t know how to do the same for IntelliJ IDEA plugin.

Now approximately 37.2% of the code for the Eclipse plugin is covered by tests. It’s not a very big value, but it’s a good start. This value was measured by EclEmma. Unfortunately we can’t use Sonar to measure this value, because our tests located in separate module. It’s a known limitation, but I suppose that this limitation can be removed, if JaCoCo plugin for Sonar would evolve. I’ve asked in dev mailing list about progress in development of this plugin, but looks like nobody works on it for now, so probably in future I’ll start work on it.

Returning to Sonar IDE : already several minor issues and two bugs in Eclipse plugin have been fixed with help from those tests.

Also I’ve created proper definitions for target platforms. So, now we can automatically check that plugin for Eclipse works under Eclipse 3.4, 3.5 and 3.6. And Olivier Gaudin helped me to do so – created job in Hudson with nightly schedule.

Next steps in testing :

  • use real Sonar server for tests;
  • increase a code coverage;
  • create tests for IntelliJ IDEA plugin.

New API

It’s not a secret that we’d like to have Sonar embedded in IDE. This was planned on version 0.3, but it requires some preparations. So, I’ve started work on a new API for accessing data stored in Sonar, inspired by a great API provided by Sonar Squid. All implementation details of API should be hidden, so in future it would be simple to switch to embedded Sonar.

I’ve already made some work on first implementation of this API : layer between IDE and Sonar, based on sonar-ws-client. In future this implementation can cache data coming from Sonar. And I hope that this API will allow us to remove annoying menu items like “refresh violations”. And again – tests helped me migrate to this API, without loosing functionality.

For now this is all, but stay tuned!

, , , ,

blog comments powered by Disqus