"use strict";(self.webpackChunkgrpc_workshop_doc=self.webpackChunkgrpc_workshop_doc||[]).push([[5125],{3905:(e,t,r)=>{r.d(t,{Zo:()=>l,kt:()=>f});var n=r(7294);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var c=n.createContext({}),p=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},l=function(e){var t=p(e.components);return n.createElement(c.Provider,{value:t},e.children)},u="mdxType",g={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},m=n.forwardRef((function(e,t){var r=e.components,i=e.mdxType,s=e.originalType,c=e.parentName,l=o(e,["components","mdxType","originalType","parentName"]),u=p(r),m=i,f=u["".concat(c,".").concat(m)]||u[m]||g[m]||s;return r?n.createElement(f,a(a({ref:t},l),{},{components:r})):n.createElement(f,a({ref:t},l))}));function f(e,t){var r=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var s=r.length,a=new Array(s);a[0]=m;var o={};for(var c in t)hasOwnProperty.call(t,c)&&(o[c]=t[c]);o.originalType=e,o[u]="string"==typeof e?e:i,a[1]=o;for(var p=2;p<s;p++)a[p]=r[p];return n.createElement.apply(null,a)}return n.createElement.apply(null,r)}m.displayName="MDXCreateElement"},6949:(e,t,r)=>{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>g,frontMatter:()=>s,metadata:()=>o,toc:()=>p});var n=r(7462),i=(r(7294),r(3905));const s={},a="Testing a gRPC service",o={unversionedId:"Day 2/Testing/index",id:"Day 2/Testing/index",title:"Testing a gRPC service",description:"https://learn.microsoft.com/en-us/aspnet/core/grpc/test-services?view=aspnetcore-7.0",source:"@site/docs/Day 2/08-Testing/index.md",sourceDirName:"Day 2/08-Testing",slug:"/Day 2/Testing/",permalink:"/docs/Day 2/Testing/",draft:!1,editUrl:"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/docs/Day 2/08-Testing/index.md",tags:[],version:"current",frontMatter:{},sidebar:"day2",previous:{title:"Health checks",permalink:"/docs/Day 2/health-checks/"},next:{title:"Unit testing",permalink:"/docs/Day 2/Testing/unit-testing"}},c={},p=[{value:"Unit testing",id:"unit-testing",level:2}],l={toc:p},u="wrapper";function g(e){let{components:t,...r}=e;return(0,i.kt)(u,(0,n.Z)({},l,r,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h1",{id:"testing-a-grpc-service"},"Testing a gRPC service"),(0,i.kt)("h1",{id:"why-test"},"Why test"),(0,i.kt)("h1",{id:"testing-with-postman"},"Testing with Postman"),(0,i.kt)("h1",{id:"testing-service-operations"},"Testing service operations"),(0,i.kt)("p",null,(0,i.kt)("a",{parentName:"p",href:"https://learn.microsoft.com/en-us/aspnet/core/grpc/test-services?view=aspnetcore-7.0"},"https://learn.microsoft.com/en-us/aspnet/core/grpc/test-services?view=aspnetcore-7.0"),"\nThere are three common approaches for testing gRPC services:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"Manual testing: Test gRPC servers with ad hoc calls.(Postman, grpCurl, etc)"),(0,i.kt)("li",{parentName:"ul"},"Unit testing: Test gRPC services directly from a unit testing library."),(0,i.kt)("li",{parentName:"ul"},"Integration testing: The gRPC app is hosted in TestServer, an in-memory test server from the ",(0,i.kt)("inlineCode",{parentName:"li"},"Microsoft.AspNetCore.TestHost")," package. gRPC services are tested by calling them using a gRPC client from a unit testing library.")),(0,i.kt)("h2",{id:"unit-testing"},"Unit testing"))}g.isMDXComponent=!0}}]);