tdd

php vendor\bin\phpunit is printing in console a text

房东的猫 提交于 2019-12-24 03:29:49
问题 I have been trying to use PHPUnit to test my app, (I installed it via Composer) but when I was trying to execute the tests that I have in my directory called "Tests" in this way: @myappsite$:php vendor\bin\phpunit Tests It just printed the content of vendor\bin\ phpunit : SRC_DIR="`pwd`" cd "`dirname "$0"`" cd "../phpunit/phpunit" BIN_TARGET="`pwd`/phpunit" cd "$SRC_DIR" "$BIN_TARGET" "$@" Somebody that has ran into this problem before and can help me please. Thanks by advance. 回答1: Ok, The

How do I test (TDD) a singleton class?

﹥>﹥吖頭↗ 提交于 2019-12-24 03:24:04
问题 I am starting with DDD and TDD in a Ruby application using Minitest. I created a repository class (no database access, but it generates the entities for me). It is a singleton. I would like to test the generation of the entities. The problem is that because it is a singleton, the order of executions of the tests affect the results. Is there any way to force the disposal of the singleton element so it is "fresh"? Here is my repository code: require "singleton" class ParticipantRepository

In code vs in script data generation for integration tests [closed]

五迷三道 提交于 2019-12-24 02:55:08
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . This question is very likely to be an opinion based. Yet I'm sure that opinion backed up with solid arguments paves the way to sound decisions. I do like to generate DB state using Autofixture. I sincerely hate writing SQL scripts and then coding expectations 'magically'

Disable Laravel exception handling for Tests

血红的双手。 提交于 2019-12-23 19:37:54
问题 I am following along this course testdrivenlaravel , and it mentions a way disable the Laravel's exception handling to prevent Laravel from handling exceptions that occur and instead throwing it, so we can get a more detailed error in our tests output. So I added this method in my testcase class, and in the render method I am throwing the exception protected function disableExceptionHandling() { $this->app->instance(Handler::class, new class extends Handler { public function __construct() { }

Ignore internal properties in ShouldBeEquivalentTo

佐手、 提交于 2019-12-23 19:11:17
问题 Is there a way to ignore internal properties of a class when doing ShouldBeEquivalentTo? For example, in the class below I want to exclude the MetaData property from the object graph comparison. public class SomeObject { Public string SomeString { get; set; } internal MetaData MetaData { get; set; } } I would prefer to not use someObject.ShouldBeEquivalentTo(someOtherObject, options => options.Excluding(info => info.SelectedMemberPath == "MetaData") Because I might have more than 1 internal

Unit-Testing delegating methods

夙愿已清 提交于 2019-12-23 14:40:42
问题 Is there any point in Unit-Testing a method that the only thing it does is delegate work on another object? Example: class abc { ... public void MoveLeft() { fallingPiece.MoveLeft(); } ... } I am doing Unit-Tests for some existing classes I have, for learning purposes. It seems kinda odd to do a Unit-Test for this MoveLeft() method, for example. But I am unsure how would it have been had I done Test-First. Thanks 回答1: Will your code break if I do this ? If it would, then you need a test to

Selenium don't show failed number lines

a 夏天 提交于 2019-12-23 13:09:17
问题 I have Selenium server working with PHPUnit on a MAMP local server. When an Assert fail, the failed number line is not showing, instead I see a phpunit number line. When I execute a "phpunit only" test I can see the number line of the failed assert. PHPUnit only test $ cd '/Applications/MAMP/htdocs/my-client/tests' && phpunit -c 'phpunit.xml' '/Applications/MAMP/htdocs/my-client/tests/controllers/homeTest.php' PHPUnit 3.6.10 by Sebastian Bergmann. Configuration read from /Applications/MAMP

Using TDD approach and avoiding Java static methods

血红的双手。 提交于 2019-12-23 12:38:55
问题 I just got some feedback about a job application Java coding exercise. They did not like the solution and two problems where stated in the feedback (which I'm very grateful for as it's very rare feedback is given): I did not use TDD approach, apparently. I overused static methods, I know static methods are anti OO but I only used them in validation and util type methods. So two questions here: What are the possible tell-tale signs of not using TDD approach? What coding style or patterns can

How to follow test first approach with Equinox/OSGi - Tycho - Eclipse RCP environment

僤鯓⒐⒋嵵緔 提交于 2019-12-23 12:27:38
问题 I joined a project where the development is carried on Eclipse RCP platform with the use of Equinox/OSGi, Tycho. I am slowly getting familiar with classpath/classloading mechanism of OSGi, how tycho, equinox works etc. I am writing plain unit tests with the use of mocking by collecting them in test bundles (which are fragments of the target bundles) however I am encountering ClassNotFound errors, issues with attaching source code. I have seen recommendations such as running tests as rcp

sniffer can't find DJANGO_SETTINGS_MODULE

自作多情 提交于 2019-12-23 12:15:44
问题 I'm trying to automate the test rerun after a change while developing. After searching around a little sniffer seemed fine. But if I run it my tests fail with this error: ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.) if I run them manually they pass. Do you have a clue why sniffer won't work? 回答1: Something like the following as your scent.py should work: from subprocess import call from sniffer.api import runnable