You need to sign in to do that
Don't have an account?
constructor error in test class
HI, New to this so treat me as dumb. Writing a unit test class for a very small class but keep getting this message
Error: Compile Error: Constructor not defined: [attachmentsample].<Constructor>() yet I used the same format in another test and it doesn't complain! what is missing? cant see the wood for the tree's i think.
** class **
public class attachmentsample {
public attachmentsample(ApexPages.StandardController controller) {
}
Public Attachment myfile;
Public Attachment getmyfile()
{
myfile = new Attachment();
return myfile;
}
Public Pagereference Savedoc()
{
String accid = System.currentPagereference().getParameters().get('id');
Attachment a = new Attachment(parentId = accid, name=myfile.name, body = myfile.body);
/* insert the attachment */
insert a;
return NULL;
}
}
** controller **
public class attachmentsampleTest {
public static void attachmentsampleTest(ApexPages.StandardController controller) {
PageReference pageRef = Page.attachment;
test.setCurrentPage(pageRef);
ApexPages.CurrentPage().getParameters().put('id', '003R000000Y7Gw4');
attachmentsample atsam = new attachmentsample();
controller.myfile.name = 'testdoc';
controller.myfile.body = 'testing 123';
}
}
Please I am really under pressure to get this stuff working but keep going round in circles.
Thanks
Steve.
Hi Steve,
Try this:
Make following changes in saveDoc method and test method :
Hope it helps.
Regards,
Devendra S
Thanks Devindra But getting Compile Error: Method does not exist or incorrect signature: [attachmentsample].SaveDoc() when saving the test code and Compile Error: Non-void method might not return a value or might have statement after a return statement. in the controller.
any ideas?
Steve
Hi Steve,
Can you please send your updated code?
Regards,
Devendra