Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Main module of program is empty: nothing will happen when it is run" warning when running xunit tests on .net core. #2669

Closed
OnurGumus opened this issue Mar 21, 2017 · 2 comments

Comments

@OnurGumus
Copy link
Contributor

Please provide a succinct description of the issue.

Repro steps

Create a test directory then from command line

  1. dotnet new xunit -lang F#

  2. dotnet add package xUnit

  3. dotnet restore

  4. dotnet test

Expected behavior

Run the tests without warnings.

Actual behavior

It generates a warning, Main module of program is empty: nothing will happen when it is run

Here's my output

C:\...\Documents\Projects\xunit_test>dotnet test
Build started, please wait...
C:\Users\onur.gumus\Documents\Projects\xunit_test\Tests.fs(8,22): warning FS0988: Main module of program is empty: nothing will happen when
it is run [C:\Users\onur.gumus\Documents\Projects\xunit_test\xunit_test.fsproj]
Build completed.

Test run for C:\Users\onur.gumus\Documents\Projects\xunit_test\bin\Debug\netcoreapp1.1\xunit_test.dll(.NETCoreApp,Version=v1.1)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
[xUnit.net 00:00:01.0591665]   Discovering: xunit_test
[xUnit.net 00:00:01.1484271]   Discovered:  xunit_test
[xUnit.net 00:00:01.1898693]   Starting:    xunit_test
[xUnit.net 00:00:01.2949161]   Finished:    xunit_test

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 2.0677 Seconds

Known workarounds

No

Related information

Windows with dotnet version 1.0.1 SDK version 1.1.0

@cloudRoutine
Copy link
Contributor

cloudRoutine commented Mar 21, 2017

this a problem with the template, netcore test projects are all console apps, and F# console apps need a function with [<EntryPoint>]

this is all you need to make the warning go away

[<EntryPoint>]
let main argv = 0


cc @enricosada

@enricosada
Copy link
Contributor

enricosada commented Mar 21, 2017

@OnurGumus it's like @cloudRoutine say, and is tracked in dotnet/netcorecli-fsc#79

@KevinRansom @OnurGumus this can be closed, the update of xunit/mstest templates is tracked in the referenced issue

JustinPealing added a commit to JustinPealing/raft-fs that referenced this issue Nov 6, 2017
Was warning "Main module of program is empty", followed advice here to fix the warning:

dotnet/fsharp#2669
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants