Open GoogleCodeExporter opened 9 years ago
I think this is a must for TDD
Original comment by agens.an...@gmail.com
on 13 Oct 2010 at 8:59
Is the only way to restrict the tests that run to create multiple testing
executables that build against different test files?
Original comment by PaulSolt
on 5 Dec 2010 at 9:26
Dave - What is the env variable trick you use to control what is run?
Original comment by thoma...@gmail.com
on 6 Dec 2010 at 1:13
[deleted comment]
In GHUnit, which is similar to GTMUnit I can pass a command line argument to
the executable to limit tests. Is something like that possible in GTM?
For example, in the Xcode executable for the test target add an argument called
TEST and provide the name of the test class to run, or the test class/test
function name to restrict it even further.
See "Running a Test Case / Single Test"
http://gabriel.github.com/gh-unit/_command_line.html
Original comment by PaulSolt
on 6 Dec 2010 at 6:38
Attachments:
That would be just great ! has anybody been able to achieve this with GTM ?
Original comment by vdau...@gmail.com
on 13 Dec 2010 at 5:01
[deleted comment]
If there isn't a workaround, you might want to consider switching to GHUnit. I
reviewed three test frameworks: OCUnit, GTMUnit, and GHUnit here:
http://paulsolt.com/2010/11/iphone-unit-testing-explained-part-1/
Original comment by PaulSolt
on 13 Dec 2010 at 5:49
Our workaround has been to create an additional test target containing
everything but actual tests. Then in an ad-hoc fashion, you can add a test to
the target. This is problematic because you have to remember to remove it again
before submitting changes.
Original comment by jon.m.r...@gmail.com
on 24 Jan 2011 at 5:53
Here's a (not very pretty) patch, simply add -DGTM_TEST=NameOfTestClass to the
CFLAGS of the unit test target.
If GTM_TEST isn't defined, all tests are run.
--- GTMIPhoneUnitTestDelegate.m (revision 439)
+++ GTMIPhoneUnitTestDelegate.m (working copy)
@@ -27,6 +27,9 @@
#import <UIKit/UIKit.h>
#import "GTMSenTestCase.h"
+#define CONVERT_SYMBOL_TO_NSSTRING_2(x) @#x
+#define CONVERT_SYMBOL_TO_NSSTRING(x) CONVERT_SYMBOL_TO_NSSTRING_2(x)
+
@interface UIApplication (GTMIPhoneUnitTestDelegate)
// SPI that we need to exit cleanly with a value.
@@ -105,12 +108,33 @@
// that are subclasses of SenTestCase. Print results and run time to
// the default output.
- (void)runTests {
- int count = objc_getClassList(NULL, 0);
- NSMutableData *classData
+ int count = 0;
+
+ Class *classes = nil;
+
+#ifdef GTM_TEST
+ Class testClass = NSClassFromString(CONVERT_SYMBOL_TO_NSSTRING(GTM_TEST));
+
+ _GTMDevAssert(testClass, @"Couldn't find GTM_TEST test class");
+
+ if(testClass)
+ {
+ Class singleTestClass[1];
+ singleTestClass[0] = testClass;
+ classes = singleTestClass;
+ count = 1;
+ }
+#else
+ count = objc_getClassList(NULL, 0);
+
+ NSMutableData *classData
= [NSMutableData dataWithLength:sizeof(Class) * count];
- Class *classes = (Class*)[classData mutableBytes];
- _GTMDevAssert(classes, @"Couldn't allocate class list");
- objc_getClassList(classes, count);
+ classes = (Class*)[classData mutableBytes];
+
+ _GTMDevAssert(classes, @"Couldn't allocate class list");
+ objc_getClassList(classes, count);
+#endif
+
totalFailures_ = 0;
totalSuccesses_ = 0;
NSString *suiteName = [[NSBundle mainBundle] bundlePath];
Original comment by insertwi...@gmail.com
on 7 Apr 2011 at 8:02
Attachments:
Original issue reported on code.google.com by
vdau...@gmail.com
on 11 Jun 2010 at 3:34