Unused methods have warning for unused and can be removed, e.g. in Eclipse
The method myMethod() from the type MyClass is never used locally
But sometimes you write code with its unit test and afterwards code isn't used (or removed) in production, but method is still used (only) for unit test
How can we find such unused methods which aren't used in real code (only test code)
- My tests are under tests folder and code under src folder
For example DAO method:
public interface TransactionDao {
public boolean updateTrasaction(int id);
}
@Repository
public class TransactionDaoImpl implements TransactionDao {
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public boolean updateTrasaction(int id) {
return (jdbcTemplate.update(... )>0);
}
}
used only in Test:
@Test
public void testUpdateTrasaction() {
Assert.assertEquals(transactionDao.updateTrasaction(1234), true);
}
I'm aware of static analysis tools and Halting Problem, but still, is there solution for this specific requirement?