How to use EMMA code coverage in android

前端 未结 3 981
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 18:32

I\'m new to EMMA, I don\'t know how to use this for android system. Can anyone please give a sample for using this with android. Thanks a lot.

3条回答
  •  醉话见心
    2021-01-31 19:25

    I've only been able to get emma working using ant. If you've got an ant build set up then you can run:

    ant emma debug install
    ant emma debug install test
    

    The first is run in your project directory, the second from your test directory. See the docs for more details: http://developer.android.com/guide/developing/building/building-cmdline.html

    If you don't have an ant build.xml file already you can see how to generate one from your current project here: http://developer.android.com/guide/developing/projects/projects-cmdline.html

    The sad part is this will only work on the emulator or a rooted device. This is because the coverage file gets generated in a folder that requires root. I also needed to modify the android-sdk/tools/ant/build.xml file to copy the file on my rooted device elsewhere so I could pull it off. I modified the emma block of the xml to be the following:

        
            
                WARNING: Code Coverage is currently only supported on the emulator and rooted devices.
                
                    
                        
                           
                           
                    
                
                Copying coverage to readable directory...
                
                    
                    
                    
                
                Downloading coverage file into project directory...
                
                    
                    
                    
                    
                
                Extracting coverage report...
                
                    
                        
                        
                            
                            
                        
                        
                        
                   
                
                Cleaning up temporary files...
                
                
                Saving the report file in ${basedir}/coverage/coverage.html
            
            
                
            
        
    

提交回复
热议问题