Automated and Manual Testing
1.1 Overview
In the Testing and Quality Assurance module, CapsureLabs ensures that each component within its ecosystem is tested thoroughly to provide a secure, stable, and high-performance platform. This section provides examples of both automated and manual testing across different system components, including REST APIs, smart contracts, and user interfaces.
1.2 Test
1.2.1 API Testing
{
"username": "testuser",
"password": "securePassword",
"email": "testuser@example.com"
}
{
"message": "User registered successfully",
"userId": "12345"
}
Automated Test Code
import requests
def test_user_registration():
url = "https://api.capsurelabs.com/api/v1/register"
payload = {
"username": "testuser",
"password": "securePassword",
"email": "testuser@example.com"
}
response = requests.post(url, json=payload)
assert response.status_code == 201
assert response.json()["message"] == "User registered successfully"
assert "userId" in response.json()
1.2.2 Smart Contract Testing
Automated Test Code
const { expect } = require("chai");
describe("ERC-20 Token Contract", function () {
let Token, token, owner, alice, bob;
beforeEach(async function () {
Token = await ethers.getContractFactory("MyToken");
[owner, alice, bob] = await ethers.getSigners();
token = await Token.deploy();
await token.mint(alice.address, 100);
});
it("should transfer tokens between accounts", async function () {
await token.connect(alice).transfer(bob.address, 20);
const aliceBalance = await token.balanceOf(alice.address);
const bobBalance = await token.balanceOf(bob.address);
expect(aliceBalance).to.equal(80);
expect(bobBalance).to.equal(20);
});
});
1.2.3 User Interface Testing
Automated Test Code
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
def test_login_redirect():
driver = webdriver.Chrome()
driver.get("https://capsurelabs.com/login")
# Enter login credentials
username_input = driver.find_element(By.NAME, "username")
password_input = driver.find_element(By.NAME, "password")
login_button = driver.find_element(By.ID, "loginButton")
username_input.send_keys("testuser")
password_input.send_keys("securePassword")
login_button.click()
# Assert redirect to dashboard
assert "Dashboard" in driver.title
driver.quit()
Last updated