Skip to content

Commit

Permalink
Merge pull request #43019 from lwpamihiranga/update-generated-test-code
Browse files Browse the repository at this point in the history
Update test code generated for service template
  • Loading branch information
azinneera authored Jul 2, 2024
2 parents fd8f0d9 + 1a2e421 commit 4052bf6
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,28 @@ import ballerina/test;
http:Client testClient = check new ("http://localhost:9090");

// Before Suite Function

@test:BeforeSuite
function beforeSuiteFunc() {
io:println("I'm the before suite function!");
}

// Test function

@test:Config {}
function testServiceWithProperName() {
string|error response = testClient->get("/greeting/?name=John");
string|error response = testClient->/greeting(name = "John");
test:assertEquals(response, "Hello, John");
}

// Negative test function

@test:Config {}
function testServiceWithEmptyName() returns error? {
http:Response response = check testClient->get("/greeting/");
http:Response response = check testClient->/greeting;
test:assertEquals(response.statusCode, 500);
json errorPayload = check response.getJsonPayload();
test:assertEquals(errorPayload.message, "name should not be empty!");
}

// After Suite Function

@test:AfterSuite
function afterSuiteFunc() {
io:println("I'm the after suite function!");
Expand Down

0 comments on commit 4052bf6

Please sign in to comment.