That is not how test methods work.
You need to actually create test data for your test code. Assuming your fields are referring to a Contact, and that Contact is a property in your class, then you actually need to create the contact first, and then test the save method
In your test Class
Contact c = new Contact(First_Name__c='Steve',Last_Name__c='Mark', Email__c='stevemark@gmail.com');
insert c;
Query_and_upload myLicenseGenerator2 = new Query_and_upload();
myLicenseGenerator2.myContact = c;
myLicenseGenerator2.save();
Assuming you use a controller property for the contact in your Query_and_upload class
public with sharing class Query_and_upload {
public Contact myContact {get;set;}
public Query_and_upload(){
myContact = new Contact();
}
public PageReference save() {
if(myContact.first_name__c.length() == 0
&& myContact.last_name__c.length() == 0
&& myContact.email__c.length() == 0 ){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,
'One of the inputs to filter the user is missing. Please enter all the fields.'));
}
}
Its also worth noting that altough this will increase your code
coverage, you really need to add some assertions so you are actually
'testing' the class. This will get you coverage, but you really
aren't testing if the class accomplishes its goal
.
Check out this article on testing best practices
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
EDIT
An example assertion
Your class has a Contact controller property that upon class instantiation, will be a new contact, with no Id.
In your test class
Contact c = new Contact(First_Name__c='Steve',Last_Name__c='Mark', Email__c='stevemark@gmail.com');
insert c;
Query_and_upload myLicenseGenerator2 = new Query_and_upload();
system.assertEquals(null, myLicenseGenerator2.myContact.Id);
myLicenseGenerator2.myContact = c;
system.assertEquals(c.Id, myLicenseGenerator2.myContact.Id);
Best Answer
If your requirement is to substring the left part before the
@
and then split this substring using the.
character, you can easily do this with the String class.