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

Code coverage in tests #4

Open
simmac opened this issue Feb 29, 2016 · 2 comments
Open

Code coverage in tests #4

simmac opened this issue Feb 29, 2016 · 2 comments

Comments

@simmac
Copy link
Owner

simmac commented Feb 29, 2016

From @m007 on March 27, 2015 9:0

Problem

Analyzed the code with my own SonarQube instance and found it having a test coverage of just about 55%.

How to find out

For anyone interested by running this analysis on your own:
I did so by adding following lines within the <build> .... </build> tag of the pom.xml file.

             <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.1.201405082137</version>

                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>pre-integration-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                            <propertyName>failsafe.argLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-integration-test</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Needless to say that you need to have a running/configured SonarQube server.

How to fix

There should be more tests. Many more tests. In 2015 nothing less than 85% is reasonable. Maybe the code should be developed test first. See TDD.

Copied from original issue: threema-ch/threema-msgapi-sdk-java#1

@simmac
Copy link
Owner Author

simmac commented Feb 29, 2016

From @m007 on March 27, 2015 9:12

Forgot to provide a picture... So, here we go:
untitled2

@simmac
Copy link
Owner Author

simmac commented Mar 2, 2016

@m007: Do you have any ideas to improve the test coverage? A lot of classes only print results in the console (all console.commands) and another big part relies on sending and receiving messages. As ECHOECHO doesn't reply to API messages (unfortunately) we can't test message sending and receiving.

But yeah, there is still room for improvement at the Exception classes and some other classes, but the major parts can't easily be tested.

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

1 participant