Browse Source

Update `Testing` document.

pull/17497/head
maliming 2 years ago
parent
commit
16999d649b
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 19
      docs/en/UI/AspNetCore/Testing.md
  2. 19
      docs/zh-Hans/UI/AspNetCore/Testing.md

19
docs/en/UI/AspNetCore/Testing.md

@ -198,23 +198,10 @@ ABP Framework doesn't provide any infrastructure to test your JavaScript code. Y
> Volo.Abp.AspNetCore.TestBase package is already installed in the `.Web.Tests` project.
This package provides the `AbpAspNetCoreIntegratedTestBase` as the fundamental base class to derive the test classes from. The `MyProjectWebTestBase` base class used above inherits from the `AbpAspNetCoreIntegratedTestBase`, so we indirectly inherited the `AbpAspNetCoreIntegratedTestBase`.
This package provides the `AbpWebApplicationFactoryIntegratedTest` as the fundamental base class to derive the test classes from. It's inherited from the [WebApplicationFactory](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests) class provided by the ASP.NET Core.
### Base Properties
The `AbpAspNetCoreIntegratedTestBase` provides the following base properties those are used in the tests:
* `Server`: A `TestServer` instance that hosts the web application in tests.
* `Client`: An `HttpClient` instance that is configured to perform requests to the test server.
* `ServiceProvider`: The service provider that you can resolve services in case of need.
### Base Methods
`AbpAspNetCoreIntegratedTestBase` provides the following methods that you can override if you need to customize the test server:
* `ConfigureServices` can be overridden to register/replace services only for the derived test class.
* `CreateHostBuilder` can be used to customize building the `IHostBuilder`.
The `MyProjectWebTestBase` base class used above inherits from the `AbpWebApplicationFactoryIntegratedTest`, so we indirectly inherited the `AbpWebApplicationFactoryIntegratedTest`.
See Also
* [Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests)
* [Overall / Server Side Testing](../../Testing.md)

19
docs/zh-Hans/UI/AspNetCore/Testing.md

@ -198,23 +198,10 @@ ABP框架不提供任何基础设施来测试JavaScript代码. 你可以使用
> Volo.Abp.AspNetCore.TestBase 已经安装在 `.Web.Tests` 项目中.
此包提供的`AbpAspNetCoreIntegratedTestBase`作为派生测试类的基类. 上面使用的`MyProjectWebTestBase`继承自`AbpAspNetCoreIntegratedTestBase`, 因此我们间接继承了`AbpAspNetCoreIntegratedTestBase`.
### 基本属性
`AbpAspNetCoreIntegratedTestBase` 提供了测试中使用的以下基本属性:
* `Server`: 在测试中托管web应用程序的`TestServer`实例.
* `Client`: 为执行对测试服务器的请求配置`HttpClient`实例.
* `ServiceProvider`: 可以在你需要时处理服务提供服务.
### 基本方法
`AbpAspNetCoreIntegratedTestBase` 提供了以下方法, 如果需要自定义测试服务器, 可以重写这些方法:
* `ConfigureServices` 仅为派生测试类注册/替换服务时可以重写使用.
* `CreateHostBuilder` 可用于自定义生成 `IHostBuilder`.
此包提供的`AbpWebApplicationFactoryIntegratedTest`作为派生测试类的基类. 它继承自ASP.NET Core提供的[WebApplicationFactory](https://learn.microsoft.com/zh-cn/aspnet/core/test/integration-tests)类。
上面使用的`MyProjectWebTestBase`继承自`AbpWebApplicationFactoryIntegratedTest`, 因此我们间接继承了`AbpWebApplicationFactoryIntegratedTest`.
另请参阅
* [ASP.NET Core 中的集成测试](https://learn.microsoft.com/zh-cn/aspnet/core/test/integration-tests)
* [总览/服务器端测试](../../Testing.md)

Loading…
Cancel
Save