Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot Test #6

Open
DoneSpeak opened this issue Apr 12, 2020 · 0 comments
Open

Spring Boot Test #6

DoneSpeak opened this issue Apr 12, 2020 · 0 comments

Comments

@DoneSpeak
Copy link
Owner

集成测试

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class AccountServiceTest {

	@Autowired
	private AccountService accountService;

	@Test
	public void createAccount() {
		Account account = new Account();
		account.setEmail("[email protected]");
		account.setFirstName("gr");
		account.setLastName("yang");
		account.setPassword("xxxxxxx");
		accountService.createAccount(account);
		List<Account> accounts = accountService.listAccounts();
		accounts.forEach(a -> log.info("{}", a));
		Assert.assertEquals(accounts.size(), 1);
	}

	@Test
	public void listAccounts() {
		List<Account> accounts = accountService.listAccounts();
		accounts.forEach(a -> log.info("{}", a));
		Assert.assertEquals(accounts.size(), 0);
	}
}

使用的是h2数据库,两个Test方法没有相互影响。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant