Giter Site home page Giter Site logo

peridot's Introduction

Peridot logo

Packagist Version Build Status HHVM Build Status Windows Build Status Scrutinizer Code Quality Codecov Coverage Gitter Chat

The highly extensible, highly enjoyable, PHP testing framework.

Read more at peridot-php.github.io or head over to the wiki.

Building PHAR

Peridot's phar is built using Box. Once box is installed, the phar can be built using the following command from the project directory:

box build

Generating Peridot's documentation

Peridot API documentation is generated using apigen. Once apigen is installed, run the following command from the project directory:

apigen generate

This will output documentation to the docs/ directory.

Running Peridot's tests

Peridot's test suite can be run using Peridot:

$ bin/peridot

And a sample of output:

Peridot output sample

Release

We use Robo for releases.

robo release [version] [site-path]

using assert for expectations

Peridot sets ASSERT_CALLBACK via assert_options in order to throw exceptions when using the native assert function. Peridot specs are considered passing if they don't throw an exception; if you are using assert for expectations and you find your specs are triggering false positives, you may need to update zend.assertions to 1 in your php.ini. This is set to -1 by default in PHP 7+

If you aren't too keen on using assert for testing, there are a ton of assertion/expectation libraries out there. Anything that throws exceptions in response to a failed assertion will do. The peridot-php org has authored Leo, and this library offers a richer assertion vocabulary for testing.

peridot's People

Contributors

austinsmorris avatar brianium avatar ezzatron avatar loalf avatar mrkrstphr avatar radiergummi avatar ragboyjr avatar themrwilliams avatar yuralukashik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peridot's Issues

Generic error interface

Related to #117 - it would probably be a good thing to have a generic error interface that can be used.

I imagine it would mirror what is already available to PHP exceptions, but create an interface for objects that are not actually exceptions.

PHP Errors

We should suppress non fatal errors and make them available to reporters.

Multiline exception messages are not indented correctly

I had a crack at integrating a mocking library I'm working on with Peridot, and ran into this small issue. Here's the output:

  Phony
    โœ“ should record passing mock assertions
    1) should record failing mock assertions


  1 passing (28 ms)
  1 failing

  1) Phony should record failing mock assertions:
     Expected call on PhonyMock_TestClassA_0[1]->testClassAMethodA with arguments like:
    <'a'>, <'b'>
Never called.
      (stack trace)

So, basically I would expect this section:

     Expected call on PhonyMock_TestClassA_0[1]->testClassAMethodA with arguments like:
    <'a'>, <'b'>
Never called.

to be rendered like:

     Expected call on PhonyMock_TestClassA_0[1]->testClassAMethodA with  arguments like:
         <'a'>, <'b'>
     Never called.

Set assert_options to throw exceptions rather than warnings

Exceptions are much are more useful for us. For now set in bootstrap and possibly make it default behavior with option to turn off?

<?php
assert_options(ASSERT_CALLBACK, function($script, $line, $message) {
    throw new \Exception($message);
});

Build process

A build process would be rad. Something that updates Console\Version, docs, and the phar and gets them where they need to go.

More modular peridot

I think a good goal for Peridot 2.0 would be to further modularize peridot if possible.

Not entirely sure on execution, but it would be great if peridot-php/peridot was a sum of core modules (core, cli, runners, concurrency?)

I think core plugins and modules would need to agree on some convention for this work - particularly with plugins, runners, etc.

Single EventEmitter

We should ditch the event emitter trait and use a single event emitter. Simplifies event handling and should make plugin/extension development easier.

Mockery::close() not work in afterEach()

    beforeEach(function() {
        $this->wapper = Mockery::mock('Wrapper');
        $this->writer = new Writer($this->wapper);
    });

    it('should write a line', function() {
        $this->wapper->shouldReceive('wrap')->once();
        $this->writer->write();
        Mockery::close();
    });

This spec will failure as my expected, because wrap() not implement.
But if I move Mockery::close() in afterEach(), it's not failure, it's not my expected.

Can not be read the autoload.php in hhvm 3.5.0 nightly

Following such an error message is displayed.
The cause seems to have happened because the path of __DIR__ is different.

[RuntimeException]                                                           
Error Output: You need to set up the project dependencies using the following commands:
curl -s http://getcomposer.org/installer | php                               
php composer.phar install

I result that tried in 3.4.0 and 3.5.0 nightly-build It was following results.

Code

#!/usr/bin/env php
<?php

$autoloaders = [
    __DIR__ . '/../../../autoload.php',
    __DIR__ . '/../vendor/autoload.php',
    __DIR__ . '/vendor/autoload.php'
];

HHVM 3.4.0

<project-path>/vendor/peridot-php/peridot/bin/../../../autoload.php
<project-path>/vendor/peridot-php/peridot/bin/../vendor/autoload.php
<project-path>/vendor/peridot-php/peridot/bin/vendor/autoload.php

HHVM 3.5.0 nightly build

<project-path>/vendor/bin/../../../autoload.php
<project-path>/vendor/bin/../vendor/autoload.php
<project-path>/vendor/bin/vendor/autoload.php

spec setups should run in order defined

This should be correct behavior for tests:

beforeEach(function() {
    $this->thing = "thing";
});

beforeEach(function() {
    $this->dependsOnThing = $this->thing . " is depended on";
});

Currently they run in reverse order.

Profile Peridot

Should probably profile this bad brother to check performance bottlenecks.

Would not hurt to run suites against other spec frameworks as well.

Logging

Peridot should minimally support JUnit XML and TAP log formats.

CLI for peridot

We need a command line executable for peridot. For now should only take a single argument that is a path to a specific spec file or a directory of specs. Eventually the runner should accept some configuration via a file (yml? json?) or as command line switches for things like loading conventions, reporter to user, etc...

peridot specs/
peridot specs/runner.spec.php

Improve grep

Right now the --grep mechanism only serves as a filename filter. It might make sense to add a different option for file names and allow --grep to match on the contents of test descriptions.

I would propose the following:

  • --grep passes a regular expression to be evaluated against it descriptions
  • add a --test-suffix option similar to PHPUnit for filtering on file names

We need a Wiki

We need a wiki demonstrating some testing with Peridot - good practices, leveraging some of BDD's strengths.

We should also make a point of stressing some of the features that distinguish Peridot - primarily events, plugins, reporters, and especially scopes.

Support pending specs

We should support some variety of pending specs - probably via x style functions:

<?php
xdescribe('A pending suite', function() {
   xit("pending spec", function() {
   });

   xcontext("pending context", function() {
   });
});

Setting properties on $this in describe is not working

This is broken again:

describe('A sandwich', function() {
    $this->sandwich = ['delicious' => true];

    it('should be delicious', function() {
        assert($this->sandwich['delicious'], "should be delicious"); //Exception: Scope property not found
    });
});

Support nested suites and context fn

We need to allow nested suites and a context function.

<?php
describe("Thing", function() {
    describe("Nested thing", function() {
        context("The nested thing is this right now", function() {
        });
    });
});

Contexts are functionally equivalent to suites.

Result reporter (pretty results)

We need a way to report failures and maybe successes? As an option? We should keep in mind that reporting should be a HIGHLY configurable part of peridot.

  • Pretty output of successes - Green dots and number of tests run?
  • Tree output of failures - as red?
  • Output trace information for exceptions
  • Convert errors to exceptions (fatal not possible)
  • Create event driven system (EventEmitter? Evenement, etc....)

Avoid static php timer calls.

Since we use the static PHP_Timer methods in the reporter, there is a chance of overwriting the data by calling PHP_Timer methods elsewhere.

It would probably make more sense to just store microtimes and use the PHP_Timer formatting function (or write our own).

Times based off of DateFormat?

Is there any reason to use the PHP_Timer class? Are there any issues with just using PHP's DateTime class and formatting it? Never a bad thing to eliminate a dependency.

Suite loader

A class responsible for loading specs

  • Load a directory of specs by convention i.e - *.spec.php
  • Return loaded file paths as array

Add file path to tests

A test should be able to see its associated file. Something like:

$suite->getFile();  // /path/to/test.spec.php

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.