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
tommytxtommytx 

Any way to prevent @isTest from removing the data it installs in salesforce.

My understanding is that when @isTest runs any data inserted into the data base is removed at the end of the program.

Is there a way to tell it not to remove the data so I can see that all is well... or is that not possible...

I am trying to get an @isTest to work for this url and am not sure its inserting the data as when the test tries to pull it out its not there. Here is a url to the test I am running.

Here is what my fails look like... they are assert fails...  When i send data to the data base via a direct email all is well but when sending from this test thingy.. negative results.... so it appears the program is ok.. just my tester is haywire

Thanks... I have been getting a lot of help here and I really appreciate it..

 

 

13:37:54.324 (324107000)|VARIABLE_ASSIGNMENT|[74]|this.message|"oops, failed again"|0x2274f8fa
13:37:54.324 (324117000)|STATEMENT_EXECUTE|[78]
13:37:54.324 (324131000)|METHOD_EXIT|[34]|01pi0000000Lm3c|EmailDemoReceive.handleInboundemail(Messaging.InboundEmail, Messaging.InboundEnvelope)
13:37:54.324 (324140000)|VARIABLE_SCOPE_BEGIN|[34]|result|Messaging.InboundEmailResult|true|false
13:37:54.324 (324178000)|VARIABLE_ASSIGNMENT|[34]|result|{"message":"oops, failed again","success":false}|0x2274f8fa
13:37:54.324 (324186000)|STATEMENT_EXECUTE|[35]
13:37:54.324 (324207000)|SYSTEM_METHOD_ENTRY|[35]|system.Test.stopTest()
13:37:54.324 (324269000)|SYSTEM_METHOD_EXIT|[35]|system.Test.stopTest()
13:37:54.324 (324276000)|STATEMENT_EXECUTE|[37]
13:37:54.324 (324287000)|HEAP_ALLOCATE|[37]|Bytes:45
13:37:54.324 (324308000)|SYSTEM_METHOD_ENTRY|[37]|System.assert(Boolean, ANY)
13:37:54.324 (324813000)|EXCEPTION_THROWN|[37]|System.AssertException: Assertion Failed: InboundEmailResult returned a failure message
13:37:54.324 (324883000)|HEAP_ALLOCATE|[37]|Bytes:67
13:37:54.324 (324895000)|SYSTEM_METHOD_EXIT|[37]|System.assert(Boolean, ANY)
13:37:54.324 (324958000)|FATAL_ERROR|System.AssertException: Assertion Failed: InboundEmailResult returned a failure message

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

There is no way to maintain the data inserted by test class. If there is any then it will defeat the purpose of test class.

 

Now, if test classes are failing where you are developing it then you can identify what is the problem by using debug logs in test class. This is how you can identify that your code is failing due to some data issue or some problem in the code itself.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

JBabuJBabu
Hi,

Can you try using system.debug statements and check the debug log?
Ankit AroraAnkit Arora

There is no way to maintain the data inserted by test class. If there is any then it will defeat the purpose of test class.

 

Now, if test classes are failing where you are developing it then you can identify what is the problem by using debug logs in test class. This is how you can identify that your code is failing due to some data issue or some problem in the code itself.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
tommytxtommytx

<quote>

There is no way to maintain the data inserted by test class. If there is any then it will defeat the purpose of test class.

 </quote>

 

so then I suppose the only way to run massive testing is to go to php or some other automated language and send a dozen emails using a php generated email so I can send say ten contacts and see if they are all ok....

 

But seems the test class could have simply been told to "Do not clean up the data base when done!"

Like @isTEST (<No Clean>)

Meaning do the insert but leave it there for review in this case... but I guess the programmers decided not to include such a command.

 

You see using Debug is so very bulky to test to see if 60 entries were added by using insert and then get to see if they went into the data base.... a simple (<No Clean>) would have been a miracle worker as debug is way too bulky... I am used to simple verification using print to screen statements.... but not allowed in apex of course....

 

But at least I got my answer.... no way Hosee......

 

Thanks

 

 

 

 

Ankit AroraAnkit Arora

You can go with selenium scripts, it will automate your process and when there is a failure it will notify you.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page