Comments (2)
Hey Clayton,
that are some interesting questions.
How to get the test/method that's currently being run?
You can get the test/method that's currently being run with __FUNCTION__
.
If you need the name of the test class and the name of function, its
either get_class($this). '->' . __FUNCTION__
or simply echo __METHOD__
.
Check also $this->getLabel()
, which retruns get_class($this)
,
if the test name wasn't set to the test class in its constructor.
(But this is the class name of a test case - not the individual test method name.)
How to access the test/method during setUp()?
This isn't possible from a UnitTestCase
.
The name of the next test method is basically $method
inside SimpleInvoker,
but there is no easy way to access it from a UnitTestCase
. One could possibly
come up with some Reflection based hacks to get access to $method
in SimpleInvoker
.
The exec flow is skip()
before setUp()
before the test $method
, see https://github.com/simpletest/simpletest/blob/master/invoker.php#L57
How to access access the test/method that's checked for skipping?
This isn't possible from a UnitTestCase
.
There is no list of tests "checked for skipping".
You can only get the skips with a Reporter
, while iterating the test methods.
For instance, the SelectiveReporter
allows to run just a single test group, a single test case or even a single assertion/test within that case.
Referencing: https://github.com/simpletest/simpletest/blob/master/reporter.php#L309
Best, Jens
from simpletest.
Thank you. This is as I suspected. I know how to get the name of the current function, but in my case I don't want to get skip
or setUp
, I wanted something like testNextTestToRun
because (for various complicated reasons) I needed to run just a single test depending on some other factors. I was hoping to be able to do something like
function skip() {
$this->skipIf( $this->getCurrentTest() == "testNextTestToRun" );
}
In the end, I ended up overriding getTests()
to return just the name of the test I wanted to run based on the "other factors" in play.
Thank you for the note about SelectiveReporter
! I will have to have a look at it and how to use it.
from simpletest.
Related Issues (20)
- assertText and <title> HOT 2
- no referer is given HOT 2
- mock_object is trying to run tell() on non existing object HOT 3
- Unable to click a button. HOT 3
- How can I add Header Referer
- [support] How to structure integration tests HOT 4
- dumper->clipString() is multibyte safe? HOT 1
- i would like commit some code HOT 6
- Mocking interfaces with class definitions in arguments is broken HOT 1
- New Release / Project Status HOT 8
- Documentation translation HOT 5
- Please support cookie/session HOT 1
- Unable to click submit when there is onclick tag HOT 2
- how to click href when there is nowrap
- PHP 7.2: Spurious test errors due to legacy constructors HOT 1
- Syntax error in mocked methods in PHP 7.1+ HOT 3
- TestSuite ends up creating instances of the clases in the hiearchy of a test
- Documentation link is broken or resource unavilable HOT 3
- Failed unit_tests.php HOT 3
- Add support for date and time input fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpletest.