Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin not working with forked execution in Grails 2.3 #11

Open
jefferysmith opened this issue Sep 20, 2013 · 5 comments
Open

Plugin not working with forked execution in Grails 2.3 #11

jefferysmith opened this issue Sep 20, 2013 · 5 comments

Comments

@jefferysmith
Copy link

The code coverage report doesn't seem to get generated when using the new forked execution introduced in Grails 2.3.
To reproduce the issue (tried on both windows and linux):

  1. create a new Grails 2.3.0 application
  2. create a simple domain class with a unit test
  3. install the latest code-coverage plugin (v1.2.6)
  4. run grails test-app -coverage
  5. the coverage report is not generated

As a workaround, you can turn off the forked execution and the code-coverage report is created.

The default Grails 2.3.0 settings in conf/BuildConfig.groovy for forking a new process:

grails.project.fork = [
    // configure settings for the test-app JVM, uses the daemon by default
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    ...
]

Then the console output includes:

| Instrumenting classes for coverage     
| Instrumenting classes for coverage.    
| Instrumenting classes for coverage..   
| Instrumenting classes for coverage...  
| Instrumenting classes for coverage.... 
| Instrumenting classes for coverage.....
...
Flushing results...                           
Flushing results done                         
Cobertura: Loaded information on 54 classes.  
Cobertura: Saved information on 54 classes.   
Flushing results...                           
Flushing results done     
...                    

If you change the setting to

grails.project.fork = [
   test: false,
   ...
]

Then the console output is as follows - and the reports are generated:

| Instrumenting classes for coverage     
| Instrumenting classes for coverage.    
| Instrumenting classes for coverage..   
| Instrumenting classes for coverage...  
| Instrumenting classes for coverage.... 
| Instrumenting classes for coverage.....
...
Flushing results...                                                                                                           
Flushing results done                                                                                                         
Cobertura: Loaded information on 54 classes.                                                                                  
Cobertura: Saved information on 54 classes.                                                                                   
Done with post processing reports in 10ms                                                                                     
| Cobertura Code Coverage Complete (view reports in: E:\work\coverage-example\target\test-reports/cobertura)                                                                                                                            
Flushing results...                                                                                                           
Flushing results done 
@ewrdk
Copy link

ewrdk commented Sep 25, 2013

The workaround works well on my local machine. It will however cause my test to crash when running on Jenkins because of classloading problems (in my case a JUnit class cannot be found).

@wrschneider
Copy link

I have also noticed that you will not get coverage from functional tests unless you change the fork run setting to false. functional tests are not impacted by the test setting.

@beckje01
Copy link
Owner

There is not currently plans for supporting forked mode, of anyone is interested in adding support a pull request is very welcome.

@jameskleeh
Copy link

@beckje01 I wouldn't mind diving into this, however I really have no idea what would need changed. Can you provide a general description of what will need changed?

@beckje01
Copy link
Owner

I really don't know where to start but with grails 3 this plugin is not needed. So it may not be worth the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants