Im a junior automation tester who is trying to improve knowledge!
What im trying to do is to test a site with differnt payments which I have standard card which includes mastercard and visa, then we have different bank such as DBS, CIMB etc etc.. which has mastercard, visa (both) and one has maybe just amex.
{
"standard": {
"visa": {
"firstName": "VISA",
"lastName": "card",
"cardNumber": "123456455467546654",
"expirationDate": "1221",
"cvv": "123"
},
"mastercard": {
"firstName": "MASTERCARD",
"lastName": "card",
"cardNumber": "124214125115125152",
"expirationDate": "1221",
"cvv": "123"
}
},
"dbs": {
"visa": {
"firstName": "VISA",
"lastName": "dbs",
"cardNumber": "23463243463263264",
"expirationDate": "1221",
"cvv": "123"
},
"mastercard": {
"firstName": "MASTERCARD",
"lastName": "dbs",
"cardNumber": "2346326324636364",
"expirationDate": "1221",
"cvv": "123"
}
},
"cimb": {
"visa": {
"firstName": "VISA",
"lastName": "CIMB",
"cardNumber": "3463434634632463246",
"expirationDate": "1221",
"cvv": "123"
},
"mastercard": {
"firstName": "MASTERCARD",
"lastName": "card",
"cardNumber": "4564567456745646",
"expirationDate": "1221",
"cvv": "123"
}
},
"mbb": {
"amex": {
"firstName": "AMEX",
"lastName": "MBB",
"cardNumber": "3425234532453245324",
"expirationDate": "1221",
"cvv": "1234"
}
},
}
So what I was trying to do is to have test cases where me as a tester can enter which kind of test I want to run lets say I want to run DBS mastercard. So what I need to do is to write in the params when starting the script following: npm e2e.js --params.cardType.dbs.mastercard
so what im trying to do is to have a basically a function that would understand that we trying to use the dbs and mastercard, take that value and test if it gives us successful payment or not.
So what I have created so far is:
const hasOneOf = (obj, keys) => keys.some(k => k in obj)
const cardType = browser.params.cardType
const getBank = cardType[`${Object.keys(cardType)[0]}`]
//${Object.keys(cardType)[0].toUpperCase() returns STANDARD or DBS or CIMB or MBB
//${Object.keys(getBank)[0].toUpperCase()} returns VISA, MASTERCARD OR AMEX
if (cardType.standard && hasOneOf(cardType.standard, ["mastercard", "visa"])) {
it(`${Object.keys(cardType)[0].toUpperCase()} - ${Object.keys(getBank)[0].toUpperCase()} - Has a form that can receive user data`,
async function () {
console.log(cardType[`${Object.keys(cardType)[0]}`])
console.log(`${Object.keys(getBank)[0].toUpperCase()}`)
});
} else if (cardType.standard && hasOneOf(cardType.standard, ["enets"])) {
it("eNets - Process payment",
async function () {
await paymentPage.eNetsPayment();
});
} else if (hasOneOf(cardType, ["dbs", "cimb", "uob", "mmb", "ocbc"])) {
it(`${Object.keys(cardType)[0].toUpperCase()} - ${Object.keys(getBank)[0].toUpperCase()} - Process payment`,
async function () {
console.log(`${Object.keys(cardType)[0].toUpperCase()}`)
console.log(`${Object.keys(getBank)[0].toUpperCase()}`)
});
}
which does the work and does goes in into the correct test case depending on the params I have given.
But my problem is that I feel like im out of the control when it comes to test purpose. so here I am asking you guys if im doing it correctly by test-purpose or what improvements can I go out of this?
Aucun commentaire:
Enregistrer un commentaire