Last active
August 21, 2020 02:10
-
-
Save tarot/43430fd7192d9dffd248 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IsTest | |
private class CalloutSampleTest { | |
public class CalloutMock implements HttpCalloutMock { | |
public HttpResponse respond(HttpRequest req) { | |
return new HttpResponse(); | |
} | |
} | |
@IsTest | |
static void test() { | |
System.runAs([select Id from User where Id = :UserInfo.getUserId()][0]) { | |
String name = EncodingUtil.convertToHex(Crypto.generateAesKey(128)); | |
insert new User( | |
LastName = name, | |
Username = name + '@example.com', | |
Email = name + '@example.com', | |
ProfileId = UserInfo.getProfileId(), | |
Alias = name.left(8), | |
TimeZoneSidKey = 'Asia/Tokyo', | |
LocaleSidKey = 'ja_JP', | |
EmailEncodingKey = 'UTF-8', | |
LanguageLocaleKey = 'ja' | |
); | |
} | |
Test.startTest(); | |
Test.setMock(HttpCalloutMock.class, new CalloutMock()); | |
HttpRequest req = new HttpRequest(); | |
req.setMethod('GET'); | |
req.setEndpoint('https://login.salesforce.com'); | |
new Http().send(req); | |
Test.stopTest(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
修正されました