-
Notifications
You must be signed in to change notification settings - Fork 23
Getting Started with Unit Tests
Matthew Little edited this page Oct 1, 2018
·
23 revisions
- .NET Core SDK (>2.1.4)
- Visual Studio Code (>1.27)
Open command line / terminal and create a new C# unit test project with the command dotnet new console --name YOUR_PROJECT_NAME
Example:
dotnet new mstest --name MyProject
Add the Meadow unit testing framework package with the command dotnet add package Meadow.UnitTestTemplate
cd MyProject
dotnet add package Meadow.UnitTestTemplate
Create a directory named contracts
to place your Solidity source files (the directory must be named contracts
).
mkdir contracts
Add your Solidity source files to the contracts
directory.
Here's an example hello world Solidity contract that we'll save to our contracts
directory as HelloWorld.sol
. Solidity source files must have the .sol
file extension.
pragma solidity ^0.4.24;
contract HelloWorld {
event HelloEvent(string _message, address _sender);
function renderHelloWorld () public returns (string) {
emit HelloEvent("Hello world", msg.sender);
return 'Hello world';
}
}
Temp - command to add latest beta package dotnet add package Meadow.UnitTestTemplate -v 0.3.185-beta -s https://www.myget.org/F/hosho/api/v3/index.json