Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Go tests in Eclipse

I have eclipse and goclipse installed, all is well, I can run a console app in the IDE. It is possible to execute the unit tests in the IDE too?

like image 494
Myles McDonnell Avatar asked Jan 21 '12 16:01

Myles McDonnell


1 Answers

The latest release of goclipse (0.7.6) does provide a means of doing testing using the "testing" package assuming you have followed the project structure recommended in C:/Go/doc/code.html in the installed file structure created when installing Go.

Using the Eclipse "run external tools" button create a new external tool configuration as follows:

  1. on the Main tab the location is C:/Go/bin/go.exe
  2. the argument is test
  3. the working directory should point to the eclipse workspace folder containing the package that is to be tested (eg ${workspace_loc:/goProject/src/pnp}, where pnp is the name of the package NOT the name of the go file that contains the test).

You can now run the test by pressing the Run button in the usual manner, having given the configuration a sensible name eg: go test pnp. You can now add further tests to the package in different go files (or the same one) and all the tests will be carried out in a manner that is expected.

like image 150
Jon Kerridge Avatar answered Sep 19 '22 07:09

Jon Kerridge