怎样用差模写测试?由于“内部”保护级别,我无法访问初始化程序

时间:2019-05-31 04:57:50

标签: ios swift

我有模块A和模块B。我的考试班用A编写。并将B导入为@testable importB。 一切正常,直到收到此警告

由于“内部”保护级别,无法访问“ Models.SetLanguage.Response”初始化程序

Model,SetLanguage的结构,响应每个定义为public

我不知道为什么我不能从模块A测试类访问B公共模块结构。

public struct  Models {

   public struct SetLanguage {
    /// Data struct sent to Interactor
    public struct Request {
      let language: Language
    }
    /// Data struct sent to Presenter
    public struct Response {
      let result: Result<Language>
    }
    /// Data struct sent to ViewController
    public struct ViewModel {
      let content: Content<Language>
    }
  }

1 个答案:

答案 0 :(得分:0)

只需使用open代替public

代码:

open struct  Models {    
   open struct SetLanguage {
    public struct Request {
      let language: Language
    }
    open struct Response {
      let result: Result<Language>
    }
    open struct ViewModel {
      let content: Content<Language>
    }
  }