Kiwi Test File Template

I'm trying to make a file template for a Kiwi test, and have two things that are messing me up right now.

1) Adding File to test target. When I create a new file using my template, it only asks me for a file name. I need to be able to tell AppCode to add the new test to my testing target.

2) Modifying the ${NAME}. I like to name my kiwi specs like this: SomeClassSpec, but I want my template to import SomeClass.h (the class that I am testing). Are there functions or string manipluations I can inside of a template so that i can chop off the last 4 letters of ${NAME}?

This is what my current template looks like:

#parse("Objective-C File Header.m")
#import <Kiwi/Kiwi.h>
#import "${NAME}.h" // this is where I want to modify name so that SomeClassSpec.h is really SomeClass.h

SPEC_BEGIN(${NAME})

SPEC_END

4 comments

Hi Jason,

To cut off the last 4 symbols you can use something like this:

#set( $LENGTH = $NAME.length() - 4 )
#import "${NAME.substring(0,$LENGTH)}.h"

Regarding your second problem, there is an issue on our tracker, feel free to vote for it: http://youtrack.jetbrains.com/issue/OC-7132

0

Thanks! Awesome! And voted :)

0

For my one future personal reference, where can I find a list of all the functions available to me in file templates?

0

We are using Velocity as a template engine, so you can refer to its documentation for all available features.

0

Please sign in to leave a comment.