From the course: Complete Guide To Java Testing with JUnit 5 & Mockito

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Challenge: Write a test class for a email validator

Challenge: Write a test class for a email validator

From the course: Complete Guide To Java Testing with JUnit 5 & Mockito

Challenge: Write a test class for a email validator

(upbeat music) - [Instructor] Let's practice writing some tests. In this challenge, you'll create a test class for an email validator. Your tests should ensure it correctly identifies valid and invalid email addresses according to some common rules. These are the common rules. The email should contain exactly one @ character. The set of characters before the @ sign we'll refer to as the local part and the character set after the @ sign we'll refer to as the domain part. The local part can contain letters, digits, dots, hyphens and underscores, but no other types of characters. The domain part should contain at least one dot and should contain letters before and after the dot. We'll refer to these sections as the domain name and top level domain. If digits do exist in the domain part, they should come in the domain name and not the top level domain. No other types of characters should be included. These are a few examples of valid and invalid emails. Let's take a look at each invalid…

Contents