Today i was trying to write some test methods and was queering an object to get some values.
but i was thrown this error
I was so like Debugging debugging and the result was coming to Null.
I tried to recollect everything i know and i did in the past.
Then i have figured it out that unless u tell your test method to see all data it will just see things that you have created @ that instance.
To make it work all you have to do is make your test method to see all data.
Hari Padmanaban showed this to me few month back but with a human tendency of forgetting things, i never thought of it and started debugging. when i realized it my self, i thought of sharing this by by posting it and starting my Bolg.
Happy Coding.
but i was thrown this error
"list has no rows for assignment to Sobject"
I crosschecked everything and found nothing was wrong.I was so like Debugging debugging and the result was coming to Null.
I tried to recollect everything i know and i did in the past.
Then i have figured it out that unless u tell your test method to see all data it will just see things that you have created @ that instance.
this can be achieved by making your first line of code to look like this
" @isTest (SeeAllData = true) "
with this your Test method will get the ability to read or Query the records of the objects.
Hari Padmanaban showed this to me few month back but with a human tendency of forgetting things, i never thought of it and started debugging. when i realized it my self, i thought of sharing this by by posting it and starting my Bolg.
hopefully this will be a good starting point for CloudSolutions...........
Happy Coding.
No comments:
Post a Comment