Unit Testing Strategy against MS Graph or Azure Ad

Brass 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/...