简体   繁体   English

测试 Spring 启动应用程序,实体模拟

[英]Testing Spring boot application, Entity mocking

i need to test this method, could you please help me, i dont know if i need mock TransferEntity data or what to do.我需要测试这个方法,你能帮我吗,我不知道我是否需要模拟 TransferEntity 数据或做什么。 Thanks in advance提前致谢

public static void setStatus(TransferEntity entity, String Status){

... } ... }

I think it depends the first things coming to minds.我认为这取决于首先想到的事情。

  • Which library are you for unit testing?你用哪个库进行单元测试? What is the content of your method?你的方法的内容是什么?

  • Are you calling another method from you method?你是从你的方法中调用另一个方法吗?

  • Do you want to perform integration test over your entity?您想对您的实体执行集成测试吗?

    If yes, you would configure database for test scope.如果是,您将为测试范围配置数据库。

  • Why you are using static method to set your entity?为什么要使用静态方法来设置实体?

In conclusion, please share more detail by sharing code block etc总之,请通过共享代码块等分享更多细节

are you performing unit testing on this method by directly calling it?您是否通过直接调用此方法对其进行单元测试? if yes then you can mock TransferEntity and use when(...).thenReturn(...) kind of snippet.如果是,那么您可以模拟 TransferEntity 并使用 when(...).thenReturn(...) 类型的片段。 but your question is very generic so difficult to answer concretely.但你的问题很笼统,很难具体回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM