An exercise template for github classroom
The idea of this template is to be able to automate the revision of the exercises created for the classes through the execution of unit tests.
- Review the TODO tree
- Implement the request
- Run the tests
Each subject has a test suite that the student must complete with all the tests passed. Based on the number of tests passed. the teacher must calculate a final grade.
The wonderful thing about this methodology is that the student is free to use its logic so that the test passes, in addition to practicing it frees its creativity and reinforces learning.
contract DataTypes {
// TODO Implement a public function with name getBooleanFromStateVariable()
// that return a true value from state variable
}
contract DataTypes {
bool private booleano;
constructor() {
booleano = true;
}
// TODO Implement a public function with name getBooleanFromStateVariable()
// that return a true value from state variable
function getBooleanFromStateVariable() public view returns(bool){
return booleano;
}
}
Note: The tests are defined by the teacher, the student only executes them
const DataTypes = artifacts.require("DataTypes");
contract("DataTypes", function (/* accounts */) {
it("should assert true", async function () {
const instance = await DataTypes.deployed();
const booleano = await instance.getBooleanFromStateVariable();
return assert.isTrue(booleano);
});
});
In this case, the following commands must be executed:
# We build our local blockchain (we only run it once)
npm run ganache
npm run test
Output
Contract: DataTypes
✔ should assert true
1 passing (133ms)