Skip to content

Instantly share code, notes, and snippets.

@finsterthecat
Last active January 16, 2018 21:09
Show Gist options
  • Save finsterthecat/ab811eefb5e208db7bc8c3778cbff709 to your computer and use it in GitHub Desktop.
Save finsterthecat/ab811eefb5e208db7bc8c3778cbff709 to your computer and use it in GitHub Desktop.
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
public class HeroesBackendApplicationTests {
private static final String BASE_URL = "/heroes/";
private static final Logger LOG = LoggerFactory.getLogger(HeroesBackendApplicationTests.class);
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
private MockMvc mvc;
// Used for converting heroes to/from JSON
private ObjectMapper mapper = new ObjectMapper();
/**
* Initialize mocks and delete all rows from Hero prior to each test.
*/
@Before
public void initTests() {
// Always start from known state, in this case 1 row in hero table.
jdbcTemplate.execute("delete from hero; insert into Hero(name) values ('Superman');");
}
@Test
public void contextLoads() {
assertThat(jdbcTemplate).isNotNull();
assertThat(mvc).isNotNull();
}
//Insert tests here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment