Unit Testing Strategy against MS Graph or Azure Ad

%3CLINGO-SUB%20id%3D%22lingo-sub-195386%22%20slang%3D%22en-US%22%3ERe%3A%20Unit%20Testing%20Strategy%20against%20MS%20Graph%20or%20Azure%20Ad%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-195386%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20able%20to%20get%20an%20answer%20from%20the%20team%20(below).%20Hope%20this%20is%20helpful%20(and%20sorry%20for%20the%20delay).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20to%20give%20a%20full%20answer%2C%20we'd%20need%20to%20know%20what%20languages%20you%20cared%20about.%20the%20key%20thing%20is%20that%20it%20should%20be%20pretty%20easy.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20terms%20of%20mocking%2C%20just%20have%20one%20method%20that%20makes%20all%20graph%20calls%20and%20use%20dependency%20injection%20to%20substitute%20an%20arbitrary%20mock.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20save%20the%20json%20responses%20of%20some%20real%20calls%20and%20have%20your%20mock%20return%20those.%20It%20should%20work%20fine%20with%20your%20favorite%20mock%20%2F%20DI%20framework%20or%20just%20make%20custom%20mocks.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20look%20at%20the%20actual%20dot%20netsdk%20for%20graph%20for%20examples%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-dotnet%2Ftree%2Fdev%2Ftests%2FMicrosoft.Graph.Core.Test%2FMocks%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmsgraph-sdk-dotnet%2Ftree%2Fdev%2Ftests%2FMicrosoft.Graph.Core.Test%2FMocks%3C%2FA%3E%20that%20uses%20Moq%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmoq%2Fmoq%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmoq%2Fmoq%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-100969%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Unit%20Testing%20Strategy%20against%20MS%20Graph%20or%20Azure%20Ad%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-100969%22%20slang%3D%22en-US%22%3E%3CP%3EAny%20update%20on%20this%3F%20Will%20Microsoft%20ever%20provide%20a%20unit%20test%20framework%20for%20their%20API's%20and%20Office%20environments%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-57524%22%20slang%3D%22en-US%22%3ERE%3A%20Unit%20Testing%20Strategy%20against%20MS%20Graph%20or%20Azure%20Ad%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-57524%22%20slang%3D%22en-US%22%3EThanks%20for%20your%20question!%20We're%20looking%20into%20this%20and%20will%20try%20to%20get%20an%20answer%20for%20you.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-50705%22%20slang%3D%22en-US%22%3EUnit%20Testing%20Strategy%20against%20MS%20Graph%20or%20Azure%20Ad%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-50705%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI'm%20trying%20to%20understand%20how%20I%20can%20create%20some%20unit%20tests%20against%20the%20MS%20graph%20API%2C%20or%20how%20to%20mock%20it%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-50705%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20AD%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Hello


I'm trying to understand how I can create some unit tests against the MS graph API, or how to mock it

 

Raul

4 Replies
Thanks for your question! We're looking into this and will try to get an answer for you.

Any update on this? Will Microsoft ever provide a unit test framework for their API's and Office environments?

I was able to get an answer from the team (below). Hope this is helpful (and sorry for the delay).

 

While to give a full answer, we'd need to know what languages you cared about. the key thing is that it should be pretty easy.

 

In terms of mocking, just have one method that makes all graph calls and use dependency injection to substitute an arbitrary mock.

 

You can save the json responses of some real calls and have your mock return those. It should work fine with your favorite mock / DI framework or just make custom mocks.

 

You can look at the actual dot netsdk for graph for examples: https://github.com/microsoftgraph/msgraph-sdk-dotnet/tree/dev/tests/Microsoft.Graph.Core.Test/Mocks that uses Moq: https://github.com/moq/moq

The link you posted is broken, since content was moved/renamed. This should be the correct updated link:
https://github.com/microsoftgraph/msgraph-sdk-dotnet/tree/dev/tests/Microsoft.Graph.DotnetCore.Test/...