-6
Class A{
    public object obj{get;set;}
}

Test Class

Class A_Test{
//how to assign value fo obj variable
}

closed as off-topic by Himanshu, Gortonington, glls, battery.cord, Samuel Dare Oct 27 '17 at 13:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Himanshu, Gortonington, glls, battery.cord, Samuel Dare
If this question can be reworded to fit the rules in the help center, please edit the question.

2
A aInstance = new A();
aInstance.obj = new Account();

I recommend you to take a look into unit-tests trailhead and Apex basics

  • This doesn't work for Getter Setter variables. it works for normal. my question is not related the test coverage its regarding assigning values from Test class to getter setter variable. this once i tried with get and set methods also. even throw method after passing value also it wont work. – Jayanth B Oct 27 '17 at 12:24
  • 1
    This doesn't work for Getter Setter variables. what do you mean? Show us example of expected and actual outcome – Oleksandr Berehovskyi Oct 27 '17 at 12:43
  • Sorry Alexander, its works perfectly. i had made some mistake in creation of dummy data in test class. Thanks for the help – Jayanth B Oct 29 '17 at 9:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.