I am running unit tests and Selenium tests in our Jenkins CI server. As we all know, tests take long to run in a large project.
Is there a tool/framework for Java which could only trigger tests whose respective source code has changed? This because not every commit to SCM affects all areas of the source code...
I am using Cobertura for code coverage and Surefire for reporting.
EDIT: I found Atlassian Clover, but I am searching for a free solution.
Unit tests can be performed manually or automated. Those employing a manual method may have an instinctual document made detailing each step in the process; however, automated testing is the more common method to unit tests. Automated approaches commonly use a testing framework to develop test cases.
Unit testing considerations What errors are commonly found during Unit Testing? (1) Misunderstood or incorrect arithmetic precedence, (2) Mixed mode operations, (3) Incorrect initialization, (4) Precision inaccuracy, (5) Incorrect symbolic representation of an expression.
Q 10 - Which of the following is correct about a Unit Test Case? A - A Unit Test Case is a part of code which ensures that the another part of code (method) works as expected.
Mocking is a process used in unit testing when the unit being tested has external dependencies. The purpose of mocking is to isolate and focus on the code being tested and not on the behavior or state of external dependencies.
I am running unit tests and Selenium tests in our Jenkins CI server. As we all know, tests take long to run in a large project.
This is the problem I'd tackle. Split your project into multiple logical units (e.g. Persistence Layer, Service Layer, Web Layer) and test them individually. That way you only need to run Selenium tests when the web layer has changed and the build time per artifact grows shorter
In general you cannot reliably infer what code is covered by what test without running it, and even when you do run your tests the execution path could be different from run to run. I suspect perfect analysis like this is equivalent to Halting Problem.
However you can infer what tests are likely to exercise changed code using either coverage from previous test run or imports in the test case files.
In the end, you do want to run your entire test suite, however, you are right that running tests over changed code is more important because 1. developer knows they messed up earlier and 2. if you experience a lot of changes, it makes sense to test newest revision first and go to earlier revisions only to bisect problems.
Google famously claimed *
that their hacked code repository runs unit tests at commit time **
and that they tweaked the test framework to determine what tests to run first. I don't know if their changes are public.
*
video talk to conference presentation, I don't recall exact name or link
**
strictly after commit, followed by automatic rollback if tests begin to fail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With