Putting my test library to use, I tried to implement a simple password strength checker. I immediately realised that I needed a better way to organize my tests and test output. The current test output looks like this:
Test `it should return strong if it contains at least 1 lowercase alphabet, at least 1 uppercase alphabet, 1 special character, 1 digit and its length is at least 8` passed.
Test `it should return weak if it contains no lowercase alphabet even though it has at least 1 uppercase alphabet, 1 special character, 1 digit and its length is at least 8` passed.
Test `it should return weak if it contains no uppcase alphabet even though it has at least 1 lowercase alphabet, 1 special character, 1 digit and its length is at least 8` passed.
Test `it should return weak if it contains no special character even though it has at least 1 lowercase alphabet, 1 uppercase alphabet, 1 digit and its length is at least 8` passed.
Test `it should return weak if it contains no digit even though it has at least 1 lowercase alphabet, 1 uppercase alphabet, 1 special character and its length is at least 8` passed.
Test `it should return moderate if its length is less than 8 but at least 6 even though it has at least 1 lowercase alphabet, 1 uppercase alphabet, 1 special character, 1 digit` passed.
Test `it should return moderate if it contains at least 1 lowercase alphabet, 1 uppercase alphabet, 1 special character and its length is at least 6` passed.
Test `it should return weak if it contains no lowercase alphabet, even though it contains at least 1 uppercase alphabet, 1 special character and its length is at least 6` passed.
Test `it should return weak if it contains no uppcase alphabet even though it has at least 1 lowercase alphabet, 1 special character and its length is at least 6` passed.
Test `it should return weak if it contains no special character even though it has at least 1 lowercase alphabet, 1 uppercase alphabet and its length is at least 6` passed.
Test `it should return weak if its length is less than 6 even though it has at least 1 lowercase alphabet, 1 uppercase alphabet and 1 special character` passed.
11 out of 11 tests passed
Ideally, I want to be able to write tests with context
and test
, not unlike how other languages organize tests:
Read more...