Created
June 4, 2018 08:12
-
-
Save yasassri/a68a1c6730644832cd05689757faa5e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/test; | |
import ballerina/io; | |
any[] outputs = []; | |
int counter = 0; | |
// This is the mock function which will replace the real function | |
@test:Mock { | |
packageName: "ballerina.io", | |
functionName: "println" | |
} | |
public function mockPrint(any... s) { | |
outputs[counter] = s[0]; | |
counter++; | |
} | |
@test:Config | |
function testFunc() { | |
// Invoking the main function | |
main(); | |
test:assertEquals("Hello, World!", outputs[0]); | |
} | |
// The main function | |
function main(string... args) { | |
io:println("Hello, World!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment