In a piece of code (exercise for a bootcamp) I had to solve some tasks. One of those tasks is to check if a String that is provided to my method has a length of exactly x digits. This String is hypothetically a social security number, so it should contain only numeric values.
Therefore, I would like to create a test that would check that all the characters in the socialSecurityNumber String are only numeric values.
I've only seen tests that use simple checks, like assertEquals (expected: 10, Actual: etc). But how would I write in a test something like "matches("[a-zA-Z]+")"?
I'm thinking
@Test
void stringTextShouldGiveError (String socialSecurityNumber){
boolean check = false;
if (socialSecurityNumber.matches("[a-zA-Z]+")){
check = true;
}
assertFalse();
How would I make the above work? Thanks