Skip to content

Instantly share code, notes, and snippets.

@jogaco
Created May 21, 2017 17:46
Show Gist options
  • Save jogaco/5223b4c4a8535fa4f4d2e73dac4ef92a to your computer and use it in GitHub Desktop.
Save jogaco/5223b4c4a8535fa4f4d2e73dac4ef92a to your computer and use it in GitHub Desktop.
Spring Boot Tutorial: tests
package com.operatornew.gamemanager;
import com.operatornew.gamemanager.domain.Game;
import com.operatornew.gamemanager.repository.GameRepository;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringBootMysqlApplicationTests {
@Autowired
private GameRepository gameRepository;
@Test
public void testLoadGames() {
List<Game> games = (ArrayList<Game>) gameRepository.findAll();
assertEquals("Did not get all games", 3, games.size());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment