F# Unit Test Error: xUnit.net / TestDriven.Net
F# Unit Test Error: xUnit.net / TestDriven.Net
所以我从 Pluralsight 和介绍课程的小伙子那里得到了以下内容,显然 运行 的代码很顺利,但是,当我 运行 它时,我收到错误消息:
"Test failed ‘T:Messaging’ : Couldn’t find type with name ‘Messaging’"
Test failed 'T: Couldn't find type with name
任何想法(赞赏)?
namespace Ploeh.Samples
open System
module Messaging =
type Envelope<'a> = {
Id : Guid
Created : DateTimeOffset
Item : 'a }
let envelop getId getTime item = {
Id = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
Created = DateTimeOffset.MinValue
Item = item }
module MessagingTests =
open Xunit
type Foo = { Text : string; Number : int }
[<Fact>]
let ``enevelope returns correct results`` () =
let getId _ = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
let getTime _ = DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) )
let item = { Text = "Bar"; Number = 42 }
let actual = Messaging.envelop getId getTime item
Assert.Equal ( Guid "1CF889F8-201F-44DF-BC86-77227651D3EE",
actual.Id )
Assert.Equal ( DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) ),
actual.Created )
Assert.Equal ( item, actual.Item )
我设法通过将测试分离到一个单独的文件和顶级模块中来让它工作。出于某种原因,除了这个“设置”之外的任何东西都不起作用,例如,单独的文件但在较低级别的模块中,或者名称空间和模块声明分别......我不确定这是否是我的目标的具体说明.Net 4.7 而不是讲师使用的任何内容或 Visual Studio 2017 的问题,或其他问题。 TestDriven.Net 似乎对 namespace/module 系统有异议并被他们弄糊涂了......
在第一个文件中:
namespace Ploeh.Samples
open System
module Messaging =
type Envelope<'a> = {
Id : Guid
Created : DateTimeOffset
Item : 'a }
let envelop getId getTime item = {
Id = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
Created = DateTimeOffset.MinValue
Item = item }
在第二个文件中:
module Ploeh.Samples.MessagingTests
open System
open Messaging
open Xunit
type Foo = { Text : string; Number : int }
[<Fact>]
let ``enevelope returns correct results`` () =
let getId _ = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
let getTime _ = DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) )
let item = { Text = "Bar"; Number = 42 }
let actual = Messaging.envelop getId getTime item
Assert.Equal ( Guid "1CF889F8-201F-44DF-BC86-77227651D3EE",
actual.Id )
Assert.Equal ( DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) ),
actual.Created )
Assert.Equal ( item, actual.Item )
所以我从 Pluralsight 和介绍课程的小伙子那里得到了以下内容,显然 运行 的代码很顺利,但是,当我 运行 它时,我收到错误消息:
"Test failed ‘T:Messaging’ : Couldn’t find type with name ‘Messaging’"
Test failed 'T: Couldn't find type with name
任何想法(赞赏)?
namespace Ploeh.Samples
open System
module Messaging =
type Envelope<'a> = {
Id : Guid
Created : DateTimeOffset
Item : 'a }
let envelop getId getTime item = {
Id = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
Created = DateTimeOffset.MinValue
Item = item }
module MessagingTests =
open Xunit
type Foo = { Text : string; Number : int }
[<Fact>]
let ``enevelope returns correct results`` () =
let getId _ = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
let getTime _ = DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) )
let item = { Text = "Bar"; Number = 42 }
let actual = Messaging.envelop getId getTime item
Assert.Equal ( Guid "1CF889F8-201F-44DF-BC86-77227651D3EE",
actual.Id )
Assert.Equal ( DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) ),
actual.Created )
Assert.Equal ( item, actual.Item )
我设法通过将测试分离到一个单独的文件和顶级模块中来让它工作。出于某种原因,除了这个“设置”之外的任何东西都不起作用,例如,单独的文件但在较低级别的模块中,或者名称空间和模块声明分别......我不确定这是否是我的目标的具体说明.Net 4.7 而不是讲师使用的任何内容或 Visual Studio 2017 的问题,或其他问题。 TestDriven.Net 似乎对 namespace/module 系统有异议并被他们弄糊涂了......
在第一个文件中:
namespace Ploeh.Samples
open System
module Messaging =
type Envelope<'a> = {
Id : Guid
Created : DateTimeOffset
Item : 'a }
let envelop getId getTime item = {
Id = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
Created = DateTimeOffset.MinValue
Item = item }
在第二个文件中:
module Ploeh.Samples.MessagingTests
open System
open Messaging
open Xunit
type Foo = { Text : string; Number : int }
[<Fact>]
let ``enevelope returns correct results`` () =
let getId _ = Guid "1CF889F8-201F-44DF-BC86-77227651D3EE"
let getTime _ = DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) )
let item = { Text = "Bar"; Number = 42 }
let actual = Messaging.envelop getId getTime item
Assert.Equal ( Guid "1CF889F8-201F-44DF-BC86-77227651D3EE",
actual.Id )
Assert.Equal ( DateTimeOffset( 636322011751405346L,
TimeSpan.FromHours(-4.0) ),
actual.Created )
Assert.Equal ( item, actual.Item )