Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing ';这';在静态模拟Mockito中不可用_Unit Testing_Testing_Junit_Mockito_Integration Testing - Fatal编程技术网

Unit testing ';这';在静态模拟Mockito中不可用

Unit testing ';这';在静态模拟Mockito中不可用,unit-testing,testing,junit,mockito,integration-testing,Unit Testing,Testing,Junit,Mockito,Integration Testing,在调试模式下运行时,我将看到this.id='this'不可用。不确定在这里设置值。我尝试使用set设置值,但仍然存在相同的问题。我正在使用intellij 在课堂上 public class Customer { private int id; public void setId(int id) { this.id=id; } public int getId() { return this.id; }

在调试模式下运行时,我将看到this.id='this'不可用。不确定在这里设置值。我尝试使用set设置值,但仍然存在相同的问题。我正在使用intellij

在课堂上

public class Customer
{
private int id;
    public void setId(int id)
     {
       this.id=id;
     }
     public int getId()
     {
       return this.id;
     }
      public void doThis(){
              try
                {
                 ResourceBundle resourcebundle=ResourceBundle.getBundle("account-local",Locale.ENGLISH);
                 if(this.id==1)
                 {
                    this.id=10;
                 }
                 else
                  {
                    this.id=15;
                  }
                }
                catch(Exception e)
                {
                } 
      }

}
静态方法具有mockito内联依赖项的测试类

public class CustomerTest
{

     @Mock
    private ResourceBundle accountManagementLocale;
     @Test
     public void doThis()
      {
    
        try (MockedStatic<ResourceBundle> utilities = Mockito.mockStatic(ResourceBundle.class)) {
            utilities.when(() -> ResourceBundle.getBundle("account-local",Locale.ENGLISH))
                    .thenReturn(accountManagementLocale);
            changeAccount.modifyAccount();
        }
      }
}
公共类客户测试
{
@嘲弄
私有资源包accountManagementLocale;
@试验
公开无效
{
try(MockedStatic实用程序=Mockito.mockStatic(ResourceBundle.class)){
utilities.when(()->ResourceBundle.getBundle(“account local”,Locale.ENGLISH))
.然后返回(accountManagementLocale);
changeAccount.modifyAccount();
}
}
}
当我在调试模式下运行时,我会看到this.id='this'不可用

我试图在网上调查,但没有找到任何解决办法