Timeline for RestResponse does not return expected statuc code in Apex Rest unit test
Current License: CC BY-SA 3.0
26 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 16, 2015 at 11:50 | comment | added | Samuel De Rycke | I only replied because I saw a lot of comments, usually that indicates that the question is not clear. When answering something in comments, it's good to also update the question so that other users can get the full info instantly. | |
Jul 16, 2015 at 10:13 | vote | accept | Oscar Tang | ||
Jul 16, 2015 at 10:13 | comment | added | Oscar Tang | @SamuelDeRycke Done. btw is that really duplicated with salesforce.stackexchange.com/questions/4988/… ? That question is suggesting to setup the RestContext in the test class before calling the Apex Rest class. Here is talking about setup the RestContext in the apex rest class for proper assertion of the RestResponse in test class right? | |
Jul 16, 2015 at 10:06 | history | edited | Oscar Tang | CC BY-SA 3.0 |
added 56 characters in body; edited title
|
Jul 16, 2015 at 7:31 | comment | added | Samuel De Rycke | Oscar, it may help if you update the question to better explain your exact question. | |
Jul 16, 2015 at 4:56 | answer | added | Oscar Tang | timeline score: 3 | |
Jul 16, 2015 at 3:07 | review | Close votes | |||
Jul 16, 2015 at 7:31 | |||||
Jul 14, 2015 at 3:58 | answer | added | Eric | timeline score: 0 | |
Jul 14, 2015 at 2:56 | comment | added | Oscar Tang | And also those five assertions are passed. The Apex rest has done their job well. | |
Jul 14, 2015 at 2:55 | comment | added | Oscar Tang | haha i see. I have updated the code block =] Actually it is working with my manual test using other rest client. It has correct status code return so I think there isn't much logically problem in my code. | |
Jul 14, 2015 at 2:54 | history | edited | Oscar Tang | CC BY-SA 3.0 |
added 3799 characters in body
|
Jul 14, 2015 at 1:20 | comment | added | Eric | @crop1645 - Haha, I know the feeling, believe me! | |
Jul 14, 2015 at 0:08 | comment | added | cropredy | @Eric -- this is not my day ...apologies | |
Jul 13, 2015 at 18:40 | comment | added | Eric | @crop1645 - See above comment. It was supposed to be Logic not login. OP did not include the Rest logic in his code that was posted | |
Jul 13, 2015 at 18:23 | comment | added | cropredy | @Eric - no login is required to test REST-annotated methods; the test is done as if the login already happened | |
Jul 13, 2015 at 14:33 | comment | added | Eric | @OscarTang - Sorry, autocorrect - Logic not login | |
Jul 13, 2015 at 6:41 | comment | added | Oscar Tang | Any further information I can provide to help you to trace the cause? Thanks in advance | |
Jul 13, 2015 at 6:40 | comment | added | Oscar Tang | @Eric How can I "Login" in an Apex REST test? Is there any reference? I have tried the apex rest endpoint without authorization header, it returns INVALID_SESSION_ID error code instead of nothing. Is there some way to add authorization message to the request in a test? | |
Jul 13, 2015 at 5:54 | comment | added | Eric | @OscarTang - Your login in the rest resource is not present. I would say there is something in your logic causing the issue. Until that is available there is no way we can tell if it is a bug or an issue with your code. | |
Jul 13, 2015 at 3:02 | comment | added | Oscar Tang | @crop1645 Actually I use runAs() in many other test cases for a long time and they work well. However this is the first time for me to use it to test in Apex REST classes. And I don't think it works well. | |
Jul 13, 2015 at 3:01 | history | edited | Oscar Tang | CC BY-SA 3.0 |
added 713 characters in body
|
Jul 10, 2015 at 16:20 | comment | added | cropredy | 1) You can definitely test with runAs(); 2) The -1 is probably because you didn't include the essence of your post-annotated method | |
Jul 10, 2015 at 7:11 | comment | added | Oscar Tang | And I am wondering why my question is -1 now. Can someone point out the problem and let me to improve my question asking skill next time? Thanks in advance. | |
Jul 10, 2015 at 7:10 | comment | added | Oscar Tang | Thanks for your reply and yes I have read it before asking this question. Is that really related to my question? My problem is to test the endpoint with different user. I can't see the post is helping me in this way. | |
Jul 10, 2015 at 6:35 | comment | added | Boris Bachovski | Have you read this? salesforce.stackexchange.com/questions/4988/… | |
Jul 10, 2015 at 6:27 | history | asked | Oscar Tang | CC BY-SA 3.0 |