我是Mockito图书馆的新手并且卡在了某个地方.
问题是当我模拟Spring jpaRepository的save方法时,我总是得到null.我在我的项目中使用这样的代码但是为了测试我已经制作了一个用于测试的虚拟代码.这些是我的代码:
// This is the class for which I am making test case
@Service("deviceManagementService")
@Scope(BRASSConstants.SCOPE_SESSION)
@Transactional
public class DeviceManagementServiceImpl implements DeviceManagementService {
public String show(){
Device device = new Device() ;
device.setContactName("abc");
Device deviceEntity = deviceDao.save(device);
System.out.println(deviceEntity); // i get this null always Why ???
return "demo";
}
}
Run Code Online (Sandbox Code Playgroud)
我写的测试用例是:
@RunWith(MockitoJUnitRunner.class)
public class DemoTest {
@InjectMocks
private DeviceManagementServiceImpl deviceManagementServiceImpl;
@Mock
private DeviceDao deviceDao;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void show(){
Device device …Run Code Online (Sandbox Code Playgroud) 我运行离子项目时遇到错误:构建Ionic 3应用程序1时出现错误
[ERROR] ionic-app-scripts has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
ionic3-firebase-shopping-cart-master anand$ ionic cordova run android
> ionic-app-scripts build --target cordova --platform android
/Users/anand/projects/Ionic/ShoppingCart/ionic3-firebase-shopping-cart-master/node_modules/node-sass/lib/binding.js:13
throw new Error(errors.unsupportedEnvironment());
^
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (64)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.5.3
at module.exports (/Users/anand/projects/Ionic/ShoppingCart/ionic3-firebase-shopping-cart-master/node_modules/node-sass/lib/binding.js:13:13)
at Object.<anonymous> (/Users/anand/projects/Ionic/ShoppingCart/ionic3-firebase-shopping-cart-master/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js …Run Code Online (Sandbox Code Playgroud)