小编use*_*ACT的帖子

方法“simulate”应在 1 个节点上运行。找到 0 个。- 笑话/酶

我正在尝试测试 onClick 但它们没有被使用道具调用:

这是 file.js 的一部分

    handleSystemClick = () => {
// var message = All unsaved changes will be lost.`
confirmAlert({
  title: 'Confirm Navigation',
  message: ' All unsaved changes will be lost.',
  childrenElement: () => <div></div>,
  confirmLabel: 'Confirm',
  cancelLabel: 'Cancel',
  onConfirm: () => {this.setState({ toSystemEntitlments: true})},
  onCancel: () => {},
})

  }
 handleCancelClick = () => {
  window.history.back();
}
Run Code Online (Sandbox Code Playgroud)

这是 file.js 的 render 方法

render()
return(
<div className='add-edit-button' id= 'test1' onClick={() => {this.handleSystemClick()}}>System</div>
<div className='add-edit-button' onClick={() => {this.handleCancelClick()}}>Cancel</div>
<div …
Run Code Online (Sandbox Code Playgroud)

unit-testing reactjs jestjs enzyme

5
推荐指数
1
解决办法
2万
查看次数

C# 异步任务 - 单元测试

我是 C# 单元测试的新手,必须测试该方法是否正常工作。

这是我到目前为止所拥有的:

  public async Task<IHttpActionResult> Post(API_FIRM_LINK aPI_FIRM_LINK)
    {
        db.API_FIRM_LINK.Add(aPI_FIRM_LINK);
        await db.SaveChangesAsync();

        return Created(aPI_FIRM_LINK);
    }
Run Code Online (Sandbox Code Playgroud)

测试方法:不确定我是否走在正确的道路上 如果有人可以根据我的测试提供示例

     public async Task PostTest()

    {
        ////Arrange
        API_FIRM_LINKController controller = new API_FIRM_LINKController();

        API_FIRM_LINK aPI_FIRM_LINK = null;

        IHttpActionResult expectedResult = await controller.Post(aPI_FIRM_LINK);
        //act

        IHttpActionResult result = await controller.Post(API_FIRM_LINK, aPI_FIRM_LINK);


        ////Assert
        IComparer<IHttpActionResult> comparer = new IHttpActionResultComparer();
       // Assert.IsTrue(comparer.Equals(expectedResult, result));

        Assert.IsNotNull(result);
        Console.Write(result);
Run Code Online (Sandbox Code Playgroud)

c# unit-testing async-await

3
推荐指数
2
解决办法
7057
查看次数

标签 统计

unit-testing ×2

async-await ×1

c# ×1

enzyme ×1

jestjs ×1

reactjs ×1