Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get name of test method in setUp (Xcode)

I want to append a message to a log that includes the name of the test method that is about to be run. I want to do this in my setUp method in my test superclass so I don't have repeated code everywhere.

I wanted to do something like this:

- (void) setUp {
    [super setUp];
    [self log:@NSStringFromSelector(_cmd)];
}

However, _cmd always gives "setUp" as its string, whereas I want "test00TestTheThing"

Is there a way to do this?

like image 379
Jonathan Chen Avatar asked Dec 10 '22 17:12

Jonathan Chen


1 Answers

I found this:

self.name

However, this gives me "-[AppUITests test00TestTheThing]"

like image 90
Jonathan Chen Avatar answered Jan 03 '23 19:01

Jonathan Chen