Comprehensive Rust(Español) 202412since_last_meal: Duration) -> bool; } fn test_robot_dog() { let mut mock_dog = MockPet::new(); mock_dog.expect_is_hungry().return_const(true); assert_eq!(mock_dog.is_hungry(Duration::from_secs(10)), true); } • Mockall other mocking libraries work in a similar fashion as Mockall, meaning that they make it easy to get a mock implementation of a given trait. 218 • Ten en cuenta que las simulaciones son algo polémicas, ya test_robot_cat() { let mut mock_cat = MockPet::new(); mock_cat .expect_is_hungry() .with(mockall::predicate::gt(Duration::from_secs(3 * 3600))) .return_const(true); mock_cat.expect_is_hungry().return_const(false);0 码力 | 389 页 | 1.04 MB | 11 月前3
共 1 条
- 1













