相关疑难解决方法(0)

f#中的参数化测试 - 这不是有效的常量表达式

出于某种原因,当通过TestCaseattrubute 将参数传递给测试时,我得到以下关于第一个参数的错误消息,在本例中是一个数组:

这不是有效的常量表达式或自定义属性值

module GameLogicTest = 
    open FsUnit
    open NUnit.Framework
    open GameLogic.Examle

    // This is not a valid constant expression or custom attribute value
    [<TestCase( [| 1; 2; 3 |], 3, 1,1)>]
    let ``let example.`` (a, m, h, c) = 
        a
        |> proof1 m
        |> should equal (h,c)
Run Code Online (Sandbox Code Playgroud)

但是当从属性和方法本身中删除最后一个参数时,一切正常.

[<TestCase( [| 1; 2; 3 |], 3, 1)>]
let ``let example.`` (a, m, h) = 
    a
    |> proof1 m
    |> should equal (h,1)
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我最好也定义一个元组int * int但它似乎也不起作用.

f# custom-attributes constant-expression fsunit parameterized-tests

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