Skip to content

Commit 1eec692

Browse files
author
Ajay kumar
committed
[Blog] [Ajay]: Add template
1 parent f60c424 commit 1eec692

File tree

3 files changed

+60
-103
lines changed

3 files changed

+60
-103
lines changed

TestArena/Blog/IntegrationTesting/handling-database/Index.razor

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,6 @@
33

44

55
<BlogContainer>
6-
<Header Title="Integration testing for dotnet core APIs: Handling database"
7-
Image="/images/blog/integration-testing/handling-database/banner.png" PublishedOn="@DateTime.Now" Authors="Ajay Kumar">
8-
</Header>
9-
10-
<Section Heading="What are integration tests in context of APIs?" Level="4">
11-
<p>In the context of <b>.NET Core APIs</b> for a blog, integration tests are automated tests that evaluate the
12-
functionality of various parts of your application working together as a whole. Specifically, these tests
13-
ensure that multiple components — such as controllers, database access, middleware, internal and external
14-
services — function correctly when integrated, as opposed to functioning correctly only in isolation (which
15-
would be covered by unit tests).</p>
16-
<p>Here is a quick one-liner summary on popular kinds of testing for an API codebase:</p>
17-
<ul>
18-
<li><b>Unit Tests:</b> Validate individual components like controllers or services in isolation.</li>
19-
<li><b>Integration Tests:</b> Verify the interaction between multiple components (e.g., API, database,
20-
middleware) as a cohesive system.</li>
21-
<li><b>Contract Tests:</b> Ensure that API endpoints conform to agreed-upon interfaces or expectations
22-
between services.</li>
23-
</ul>
24-
<p>Integration tests will help you in identifying possible bugs introduced due to any new changes in your code.
25-
</p>
26-
27-
<BlogImage ImagePath="/images/blog/integration-testing/intro/Build process when integration tests fail.webp"
28-
Description="Build process when integration tests fail" Number="1" />
29-
30-
<CodeSnippet Description="APIs for SuperHero" Number="1">
31-
[ApiController]
32-
[Route("[controller]")]
33-
public class SuperHeroController(ISuperHeroRepository superHeroRepository)
34-
: ControllerBase
35-
{
36-
[HttpGet("")]
37-
public async Task&lt;IEnumerable&lt;SuperHero&gt;&gt; Get()
38-
{
39-
return await superHeroRepository.GetAllSuperHeroes();
40-
}
41-
42-
[HttpGet("{id}")]
43-
public async Task&lt;IActionResult&gt; GetById(int id)
44-
{
45-
var superHero = await superHeroRepository.GetSuperHeroById(id);
46-
if (superHero == null)
47-
{
48-
return NotFound();
49-
}
50-
51-
return Ok(superHero);
52-
}
53-
}
54-
</CodeSnippet>
55-
</Section
56-
576
<Section Heading="Summary" Level="4">
587
<p>Welcome to the 2nd post in our Integration testing series. You may check out the previous post that introduces the concept of writing integration tests using <b>WebApplicationFactory</b> in dotnet below:</p>
598
<BlogReferenceCard Title="Integration testing for dotnet core APIs: Introduction"

TestArena/Blog/IntegrationTesting/handling-external-services/Index.razor

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,6 @@
88
Authors="Ajay Kumar">
99
</Header>
1010

11-
<Section Heading="What are integration tests in context of APIs?" Level="4">
12-
<p>In the context of <b>.NET Core APIs</b> for a blog, integration tests are automated tests that evaluate the
13-
functionality of various parts of your application working together as a whole. Specifically, these tests
14-
ensure that multiple components — such as controllers, database access, middleware, internal and external
15-
services — function correctly when integrated, as opposed to functioning correctly only in isolation (which
16-
would be covered by unit tests).</p>
17-
<p>Here is a quick one-liner summary on popular kinds of testing for an API codebase:</p>
18-
<ul>
19-
<li><b>Unit Tests:</b> Validate individual components like controllers or services in isolation.</li>
20-
<li><b>Integration Tests:</b> Verify the interaction between multiple components (e.g., API, database,
21-
middleware) as a cohesive system.</li>
22-
<li><b>Contract Tests:</b> Ensure that API endpoints conform to agreed-upon interfaces or expectations
23-
between services.</li>
24-
</ul>
25-
<p>Integration tests will help you in identifying possible bugs introduced due to any new changes in your code.
26-
</p>
27-
28-
<BlogReferenceCard Title="Integration testing for dotnet core APIs: Introduction"
29-
Description="Integration testing for dotnet core APIs: Introduction"
30-
Url="/blog/integration-testing-in-dotnet-intro" ImageUrl="/images/blog/integration-testing/intro/banner.png"
31-
Source="devcodex.in" />
32-
33-
<BlogImage ImagePath="/images/blog/integration-testing/intro/Build process when integration tests fail.webp"
34-
Description="Build process when integration tests fail" Number="1" />
35-
36-
<CodeSnippet Description="APIs for SuperHero" Number="1">
37-
[ApiController]
38-
[Route("[controller]")]
39-
public class SuperHeroController(ISuperHeroRepository superHeroRepository)
40-
: ControllerBase
41-
{
42-
[HttpGet("")]
43-
public async Task&lt;IEnumerable&lt;SuperHero&gt;&gt; Get()
44-
{
45-
return await superHeroRepository.GetAllSuperHeroes();
46-
}
47-
48-
[HttpGet("{id}")]
49-
public async Task&lt;IActionResult&gt; GetById(int id)
50-
{
51-
var superHero = await superHeroRepository.GetSuperHeroById(id);
52-
if (superHero == null)
53-
{
54-
return NotFound();
55-
}
56-
57-
return Ok(superHero);
58-
}
59-
}
60-
</CodeSnippet>
61-
</Section
62-
6311
<Section Heading="Summary" Level="4">
6412
<p>This is a continuation of the <b>Integration testing in dotnet</b> series. This time we will be covering the
6513
scenario where third-party service calls are present in our API flows.</p>

TestArena/Blog/Template.razor

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@page "/blog/path-to-article"
2+
@using TestArena.Blog.Common
3+
<BlogContainer>
4+
<Header Title="Integration testing for dotnet core APIs: Handling 3rd party service calls using wiremock"
5+
Image="/images/blog/integration-testing/handling-external-services/banner.png" PublishedOn="@DateTime.Now"
6+
Authors="Ajay Kumar">
7+
</Header>
8+
9+
<Section Heading="What are integration tests in context of APIs?" Level="4">
10+
<p>In the context of <b>.NET Core APIs</b> for a blog, integration tests are automated tests that evaluate the
11+
functionality of various parts of your application working together as a whole. Specifically, these tests
12+
ensure that multiple components — such as controllers, database access, middleware, internal and external
13+
services — function correctly when integrated, as opposed to functioning correctly only in isolation (which
14+
would be covered by unit tests).</p>
15+
<p>Here is a quick one-liner summary on popular kinds of testing for an API codebase:</p>
16+
<ul>
17+
<li><b>Unit Tests:</b> Validate individual components like controllers or services in isolation.</li>
18+
<li><b>Integration Tests:</b> Verify the interaction between multiple components (e.g., API, database,
19+
middleware) as a cohesive system.</li>
20+
<li><b>Contract Tests:</b> Ensure that API endpoints conform to agreed-upon interfaces or expectations
21+
between services.</li>
22+
</ul>
23+
<p>Integration tests will help you in identifying possible bugs introduced due to any new changes in your code.
24+
</p>
25+
26+
<BlogReferenceCard Title="Integration testing for dotnet core APIs: Introduction"
27+
Description="Integration testing for dotnet core APIs: Introduction"
28+
Url="/blog/integration-testing-in-dotnet-intro" ImageUrl="/images/blog/integration-testing/intro/banner.png"
29+
Source="devcodex.in" />
30+
31+
<BlogImage ImagePath="/images/blog/integration-testing/intro/Build process when integration tests fail.webp"
32+
Description="Build process when integration tests fail" Number="1" />
33+
34+
<CodeSnippet Description="APIs for SuperHero" Number="1">
35+
[ApiController]
36+
[Route("[controller]")]
37+
public class SuperHeroController(ISuperHeroRepository superHeroRepository)
38+
: ControllerBase
39+
{
40+
[HttpGet("")]
41+
public async Task&lt;IEnumerable&lt;SuperHero&gt;&gt; Get()
42+
{
43+
return await superHeroRepository.GetAllSuperHeroes();
44+
}
45+
46+
[HttpGet("{id}")]
47+
public async Task&lt;IActionResult&gt; GetById(int id)
48+
{
49+
var superHero = await superHeroRepository.GetSuperHeroById(id);
50+
if (superHero == null)
51+
{
52+
return NotFound();
53+
}
54+
55+
return Ok(superHero);
56+
}
57+
}
58+
</CodeSnippet>
59+
</Section>
60+
</BlogContainer>

0 commit comments

Comments
 (0)