Skip to content

Instantly share code, notes, and snippets.

@tarot
Last active August 21, 2020 02:10
Show Gist options
  • Save tarot/43430fd7192d9dffd248 to your computer and use it in GitHub Desktop.
Save tarot/43430fd7192d9dffd248 to your computer and use it in GitHub Desktop.
@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();
}
}
@tarot
Copy link
Author

tarot commented Oct 30, 2015

修正されました

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment