Skip to content

Instantly share code, notes, and snippets.

@vanessagl2
Last active June 18, 2019 13:44
Show Gist options
  • Save vanessagl2/c0c3cfc69ff561184701da881d6f84b4 to your computer and use it in GitHub Desktop.
Save vanessagl2/c0c3cfc69ff561184701da881d6f84b4 to your computer and use it in GitHub Desktop.
Build Gradle base java junit code
Given a number, the program should:
Return "Fizz" if the number is a multiple of 3;
Return "Buzz" if the number is a multiple of 5;
Return "FizzBuzz" if the number is a multiple of both.
Return the same number if the number is not a multiple of one of them or both;
import fizzbuzz.FizzBuzz;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class FizzBuzzTest {
@Test
public void shouldReturnFizzWhenNumberIsMultipleOf3() {
int number = 3;
FizzBuzz fizzBuzz = new FizzBuzz();
String convertedNumber = fizzBuzz.convert(number);
assertThat(convertedNumber, is("fizz"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment