paulstringer / OCSlimProject

Lightweight Xcode Project wrapper to help you get setup writing fast, rock solid, non UI based Acceptance Tests using Fitnesse
http://paulstringer.github.io/OCSlimProject
MIT License
69 stars 9 forks source link

Fitnesse function with multiple parameters #31

Open gkolodziej opened 5 years ago

gkolodziej commented 5 years ago

I am trying to create acceptance test with function with multiple parameters but all the time when test is run, I receive 'not found in...' exception. According to http://fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.ScriptTable both function calls should works.

Fitnesse table:

!define TEST_SYSTEM {slim}
|Script: My Test                                |
|login with username | Bob | and password | zxc | 

or

|login with username and password; | Bob | zxc | 

Fixture:

@objc(MyTest)
class MyTest: NSObject {
    let userName = "Bob"
    let password = "zxc"

    @objc func loginWithUsernameAndPassword(_ userName: String, _ password: String) -> Bool {
        let result = self.userName ==  userName && self.password == password
        return result
    }
}

No matter if I use _ for parameter name or not. Functions with one parameter or variables works fine. Is this some internal error or configuration issue?

dcutting commented 5 years ago

I think you need to make a single parameter which is an array of Strings:

    @objc func loginWithUsernameAndPassword(_ params: [String]) -> Bool {
        let result = self.userName ==  params[0] && self.password == params[1]
        return result
    }
gkolodziej commented 5 years ago

@dcutting thanks for your answer bun I know how to write workaround for that. I was asking rather why multiple parameters function does not work when this is described in official fitnesse user guide.

dcutting commented 5 years ago

I believe that's just an implementation detail of the ObjectiveCSlim library used by OCSlimProject.

The documentation in the FitNesse user guide is assuming your fixture is in Java, but the Objective C implementation doesn't seem to work quite the same. I agree it's confusing - it takes a lot of trial and error to figure out how it all works in iOS.