• sa_na
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I have problems testing my getter/setter. I'm rather new to it and am missing the nuances.

 

I have a class that looks like this:

  

public with sharing class clsCheckDuplicateSerials {
	public string CheckDuplicateSerials{get; set;}
	  String srchText;
	  	  
	  public String getSearchText() {
	    return srchText;
	  }
	  public void setSearchText(String s) {
	    srchText = s;
	  }
}

 The test method looks like this:

@isTest
private class TestDuplicateISerials {
    static testMethod void myUnitTest() {
        String sText ='ABX9043092058';
        CheckDuplicateSerials mm= new CheckDuplicateSerials();
        mm.getSearchText =sText;
        String s = mm.getSearchText ;
        systemAssert(sText,s)
    }
}

 

This doesn't work, I get "Variable does not exist: getSearchText". I have tried different methods of assignment but only the error messages change.

 

It's the test class that fails, the first one doesn't throw any errors.

 

I'm aware of the issue with execution order of the getter and setter but ignoring it for the moment, just want to be able to get the testing going.

 

Any advice?

 

/Mats