Q:

Skipping execution of a few lines in eclipse (or netBeans) during testing

I recently wrote my first program, a console application that emails the contents of folders in a target directory, before deleting both the files and folders from my hard drive. Now I'd like to make it interactive, giving me choice the choice to select which emails to send, before turning it into a JavaFX project.
The problem is, I have to either recreate the folders and files and delete emails every time I run the program or manually comment out the transport() and delete() lines anytime I want to test my app.  This is becoming increasingly time consuming now that I'm creating the logic behind the console interaction.
I'm sure my current IDE, Eclipse should have a way to stop code from executing while testing, but I'm having trouble finding it in eclipse or on google since I'm fairly new to programming and probably just don't know the name of the feature I'm looking for. As an aside, The JavaFX book I picked up has me studying on NetBeans, it'd be nice to know a way to do the same with it as well while I learn and decide which IDE I'll end up using in the future.

A:

Generally, when you want to test a section of your code without running the entire application you would design and run a unit test. The general procedure is to define what the expected output of a function would be given the proper input and then create a separate test class which will drive the inputs into your function. For instance given your function adds to int's your test method might be:
//Testing additive function
@Test
public void testAddFunction() 
{
    int a = 1 ; int b = 1;
    assertEquals(2, YourClass.addInt(x,y));
}

As you can see, the method addInt is created by you and assertEquals tests that method by checking if its output is the expected value you entered, in this case the number 2.
Each IDE has its own method of creating a UnitTest. For instance, in NetBeans you would open the project you intend to test then move to: Tools:Create/Update Tests. I don't use Eclipse but I believe it is as simple as right-clicking the current .java file and creating a jUnitTest.
There is a plethora of information on the Internet about how to design and use unit tests, so GL!

