If the question is really this:
How to skip code section when deleting in java
then I agree with the answers. Inclusion of dependencies, mocking frameworks - this is absolutely the right way to conduct true unit testing.
However, if the question is:
How to skip a section of code when using JUnit (or another unit testing framework)
Then I think the answer is "it depends." Sometimes I use JUnit to test integration - fragments of client code that I run on a test server to save me from having to run these tests on the client side manually through a graphical interface. In this case, I use system properties, for example, in my base class:
protected boolean skipTest() { String port = System.getProperty("jersey.test.port");
Then in the actual test class it looks like this:
// verify a successful login @Test public void testLogin() { if (skipTest()) return; // do real test
So, I thought that if you really cannot reorganize the Oracle material from your DAO, then you really do an integration test, and it is ok to have skipTest in the unit test.
source share