function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dave StevensonDave Stevenson 

Constructor not defined: [ParseSystemOverview].(String)

I have read lots of posts about this error message, and cannot figure this out. Here is the relevant of my class, including the constructors:
 
global class ParseSystemOverview {
    private String testContent;
    
    global void ParseSystemOverview() {
    }

    global void ParseSystemOverview(String tstContent) {
        // For use by unit tests - pass in sample content
        testContent = tstContent;
    }
}

And here is the client code:
 
@isTest private class ParseSystemOverviewTest {
    static testMethod void apiUsageTest() {
        String testPageContent = 'Hello there.';
        ParseSystemOverview parse = new ParseSystemOverview(testPageContent);
    }
}

The compiler error 'Constructor not defined: [ParseSystemOverview].(String)' occurs on line 4 o fmy unit test. Help please. And thanks.
 
Best Answer chosen by Dave Stevenson
Alain CabonAlain Cabon
Hi,
 
global class ParseSystemOverview {
    private String testContent;
    
    global ParseSystemOverview() {
    }

    global ParseSystemOverview(String tstContent) {
        // For use by unit tests - pass in sample content
        testContent = tstContent;
    }
}

Regards

Alain

All Answers

Alain CabonAlain Cabon
Hi,
 
global class ParseSystemOverview {
    private String testContent;
    
    global ParseSystemOverview() {
    }

    global ParseSystemOverview(String tstContent) {
        // For use by unit tests - pass in sample content
        testContent = tstContent;
    }
}

Regards

Alain
This was selected as the best answer
Dave StevensonDave Stevenson
No void return type for constructors. Got it. Thank you!