├── scala ├── src │ ├── main │ │ ├── java │ │ │ └── .gitkeep │ │ ├── resources │ │ │ └── .gitkeep │ │ └── scala │ │ │ └── com │ │ │ └── dojo │ │ │ └── kata │ │ │ └── Kata.scala │ └── test │ │ ├── java │ │ └── .gitkeep │ │ ├── resources │ │ └── .gitkeep │ │ └── scala │ │ └── com │ │ └── dojo │ │ └── kata │ │ ├── Kata1Test.scala │ │ └── Kata2Test.scala ├── build.sbt ├── readme.md └── .gitignore ├── java ├── java-maven │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── .gitkeep │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── dojo │ │ │ │ └── kata │ │ │ │ └── Kata.java │ │ └── test │ │ │ ├── resources │ │ │ └── .gitkeep │ │ │ └── java │ │ │ └── com │ │ │ └── dojo │ │ │ └── kata │ │ │ └── KataTest.java │ └── .gitignore ├── java-graddle │ ├── src │ │ ├── main │ │ │ ├── resources │ │ │ │ └── .gitkeep │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── dojo │ │ │ │ └── kata │ │ │ │ └── Kata.java │ │ └── test │ │ │ ├── resources │ │ │ └── .gitkeep │ │ │ └── java │ │ │ └── com │ │ │ └── dojo │ │ │ └── kata │ │ │ └── KataTest.java │ ├── settings.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew └── readme.md ├── groovy ├── src │ ├── main │ │ └── groovy │ │ │ └── com │ │ │ └── dojo │ │ │ └── kata │ │ │ └── .gitkeep │ └── test │ │ └── groovy │ │ └── com │ │ └── dojo │ │ └── kata │ │ └── KataSpec.groovy ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── readme.md ├── .gitignore ├── build.gradle ├── config │ └── codenarc │ │ ├── rules-test.groovy │ │ └── rules.groovy ├── gradlew.bat └── gradlew ├── php ├── with-atoum │ ├── .gitignore │ ├── src │ │ ├── Domain │ │ │ └── User │ │ │ │ ├── UserException.php │ │ │ │ ├── UserRepositoryInterface.php │ │ │ │ ├── UserId.php │ │ │ │ └── User.php │ │ └── Infrastructure │ │ │ ├── Provider │ │ │ ├── DataProviderException.php │ │ │ ├── DataProviderInterface.php │ │ │ └── ArrayDataProvider.php │ │ │ └── User │ │ │ └── UserRepository.php │ ├── composer.json │ ├── README.md │ ├── tests │ │ ├── Domain │ │ │ └── User │ │ │ │ ├── UserId.php │ │ │ │ └── User.php │ │ └── Infrastructure │ │ │ ├── User │ │ │ └── UserRepository.php │ │ │ └── Provider │ │ │ └── ArrayDataProvider.php │ ├── .bootstrap.atoum.php │ └── .atoum.php ├── with-phpspec-offline │ ├── phpspec.phar │ ├── .editorconfig │ ├── README.md │ └── Makefile ├── with-phpspec │ ├── composer.json │ ├── .editorconfig │ ├── README.md │ └── Makefile └── with-phpunit │ ├── src │ └── Dummy.php │ ├── .editorconfig │ ├── composer.json │ ├── tests │ └── DummyTest.php │ └── Makefile ├── python ├── python2 │ ├── Makefile │ ├── main.py │ └── tests.py └── .gitignore ├── js ├── with-jest │ ├── jest-babel │ │ ├── .babelrc │ │ ├── lib │ │ │ └── sum.js │ │ ├── __tests__ │ │ │ ├── sum.test.js │ │ │ └── sum.spec.js │ │ ├── package.json │ │ └── how-to-build.md │ ├── jest │ │ ├── lib │ │ │ └── sum.js │ │ ├── __tests__ │ │ │ ├── sum.test.js │ │ │ └── sum.spec.js │ │ ├── package.json │ │ └── how-to-build.md │ └── .editorconfig ├── with-mocha │ ├── mocha │ │ ├── mocha.opts │ │ ├── package.json │ │ ├── .editorconfig │ │ ├── test │ │ │ └── sample.test.js │ │ └── how-to-build.md │ ├── mocha-babel │ │ ├── mocha.opts │ │ ├── src │ │ │ ├── Song.js │ │ │ └── Player.js │ │ ├── package.json │ │ ├── .editorconfig │ │ ├── test │ │ │ └── PlayerSpec.js │ │ └── how-to-build.md │ ├── mocha-karma-babel │ │ ├── src │ │ │ ├── Song.js │ │ │ └── Player.js │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── test │ │ │ └── PlayerSpec.js │ │ ├── karma.conf.js │ │ └── how-to-build.md │ └── mocha-karma │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── test │ │ └── sample.test.js │ │ ├── karma.conf.js │ │ └── how-to-build.md ├── with-jasmine │ ├── jasmine-htmlrunner │ │ ├── lib │ │ │ └── jasmine-2.3.4 │ │ │ │ ├── jasmine_favicon.png │ │ │ │ ├── boot.js │ │ │ │ └── console.js │ │ ├── src │ │ │ ├── Song.js │ │ │ └── Player.js │ │ ├── spec │ │ │ ├── SpecHelper.js │ │ │ └── PlayerSpec.js │ │ ├── .editorconfig │ │ ├── SpecRunner.html │ │ ├── how-to-build.md │ │ └── MIT.LICENSE │ ├── jasmine-karma-coffeescript │ │ ├── src │ │ │ ├── Song.coffee │ │ │ ├── calculator.coffee │ │ │ └── Player.coffee │ │ ├── spec │ │ │ ├── helper │ │ │ │ └── spec-helper.coffee │ │ │ ├── calculator.spec.coffee │ │ │ └── player.spec.coffee │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── karma.conf.coffee │ │ ├── karma.conf - Copie.coffee │ │ └── how-to-build.md │ ├── jasmine │ │ ├── spec │ │ │ ├── support │ │ │ │ └── jasmine.json │ │ │ ├── helpers │ │ │ │ └── jasmine_examples │ │ │ │ │ └── SpecHelper.js │ │ │ └── jasmine_examples │ │ │ │ └── PlayerSpec.js │ │ ├── lib │ │ │ └── jasmine_examples │ │ │ │ ├── Song.js │ │ │ │ └── Player.js │ │ ├── package.json │ │ ├── .editorconfig │ │ └── how-to-build.md │ ├── jasmine-karma │ │ ├── spec │ │ │ ├── support │ │ │ │ └── jasmine.json │ │ │ ├── helpers │ │ │ │ └── jasmine_examples │ │ │ │ │ └── SpecHelper.js │ │ │ └── jasmine_examples │ │ │ │ └── PlayerSpec.js │ │ ├── src │ │ │ └── jasmine_examples │ │ │ │ ├── Song.js │ │ │ │ └── Player.js │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── karma.conf.js │ │ └── how-to-build.md │ ├── jasmine-karma-typescript │ │ ├── src │ │ │ └── hello-world.ts │ │ ├── spec │ │ │ └── hello-world.test.ts │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── karma.conf.js │ │ └── how-to-build.md │ └── jasmine-karma-babel │ │ ├── src │ │ ├── song.js │ │ └── player.js │ │ ├── spec │ │ ├── spec-helper.js │ │ └── player.spec.js │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── karma.conf.js │ │ └── how-to-build.md ├── with-qunit │ ├── qunit-htmlrunner │ │ ├── TestRunner.html │ │ ├── .editorconfig │ │ ├── test │ │ │ └── sample.test.js │ │ ├── how-to-build.md │ │ └── lib │ │ │ └── qunit-1.18.0.css │ └── qunit-karma │ │ ├── .editorconfig │ │ ├── package.json │ │ ├── test │ │ └── sample.test.js │ │ ├── karma.conf.js │ │ └── how-to-build.md ├── .gitignore ├── readme.md └── references.md ├── more.md ├── cpp └── cmake │ ├── src │ ├── fizz_buzz.cpp │ └── CMakeLists.txt │ ├── tests │ ├── unit_tests │ │ ├── test_fizz_buzz.cpp │ │ └── CMakeLists.txt │ └── CMakeLists.txt │ ├── .gitignore │ ├── main.cpp │ ├── CMakeLists.txt │ └── README.md ├── go ├── simple.go ├── .gitignore ├── simple_test.go └── readme.md ├── .editorconfig ├── .gitignore └── readme.md /scala/src/main/java/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scala/src/test/java/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scala/src/main/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scala/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java/java-maven/src/main/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java/java-maven/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /groovy/src/main/groovy/com/dojo/kata/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java/java-graddle/src/main/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java/java-graddle/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /php/with-atoum/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock 3 | -------------------------------------------------------------------------------- /java/java-graddle/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kata' 2 | -------------------------------------------------------------------------------- /groovy/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'kata-groovy' 2 | 3 | -------------------------------------------------------------------------------- /python/python2/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | python -m unittest tests 3 | -------------------------------------------------------------------------------- /python/python2/main.py: -------------------------------------------------------------------------------- 1 | def get_green(): 2 | return 'red' 3 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /js/with-mocha/mocha/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter dot 2 | --ui bdd 3 | --recursive 4 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter dot 2 | --ui bdd 3 | --recursive 4 | -------------------------------------------------------------------------------- /js/with-jest/jest/lib/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = (a, b) => a + b; 4 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/lib/sum.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = (a, b) => a + b; 4 | -------------------------------------------------------------------------------- /more.md: -------------------------------------------------------------------------------- 1 | # More 2 | 3 | A collection of useful `.gitignore` templates : https://github.com/github/gitignore 4 | -------------------------------------------------------------------------------- /java/java-graddle/src/main/java/com/dojo/kata/Kata.java: -------------------------------------------------------------------------------- 1 | package com.dojo.kata; 2 | 3 | public class Kata { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /java/java-maven/src/main/java/com/dojo/kata/Kata.java: -------------------------------------------------------------------------------- 1 | package com.dojo.kata; 2 | 3 | public class Kata { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /php/with-phpspec-offline/phpspec.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldez/kata-starter/HEAD/php/with-phpspec-offline/phpspec.phar -------------------------------------------------------------------------------- /groovy/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldez/kata-starter/HEAD/groovy/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /cpp/cmake/src/fizz_buzz.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | string FizzBuzz(int number) { 6 | return ""; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /java/java-graddle/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldez/kata-starter/HEAD/java/java-graddle/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /php/with-atoum/src/Domain/User/UserException.php: -------------------------------------------------------------------------------- 1 | { 6 | expect(sum(1, 2)).toBe(3); 7 | }); 8 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/lib/jasmine-2.3.4/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldez/kata-starter/HEAD/js/with-jasmine/jasmine-htmlrunner/lib/jasmine-2.3.4/jasmine_favicon.png -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/src/Song.coffee: -------------------------------------------------------------------------------- 1 | class Song 2 | 3 | persistFavoriteStatus: (value) -> 4 | # something complicated 5 | throw new Error('not yet implemented') 6 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/__tests__/sum.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const sum = require('../lib/sum.js'); 4 | 5 | test('adds 1 + 2 to equal 3', () => { 6 | expect(sum(1, 2)).toBe(3); 7 | }); 8 | -------------------------------------------------------------------------------- /php/with-phpspec/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "autoload": { 3 | "psr-0": { 4 | "": "src" 5 | } 6 | }, 7 | "require-dev": { 8 | "phpspec/phpspec": "^4.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": [ 4 | "**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "helpers/**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/spec/support/jasmine.json: -------------------------------------------------------------------------------- 1 | { 2 | "spec_dir": "spec", 3 | "spec_files": [ 4 | "**/*[sS]pec.js" 5 | ], 6 | "helpers": [ 7 | "helpers/**/*.js" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/src/Song.js: -------------------------------------------------------------------------------- 1 | export default class Song { 2 | 3 | persistFavoriteStatus(value) { 4 | // something complicated 5 | throw new Error('not yet implemented'); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /php/with-atoum/src/Infrastructure/Provider/DataProviderException.php: -------------------------------------------------------------------------------- 1 | 2 | #include "src/fizz_buzz.cpp" 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | for (int i = 1; i < 100; i++) { 8 | cout << FizzBuzz(i) << " "; 9 | } 10 | cout << endl; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /python/python2/tests.py: -------------------------------------------------------------------------------- 1 | import main 2 | import unittest 3 | 4 | 5 | class TestMain(unittest.TestCase): 6 | def test_is_red(self): 7 | self.assertEqual(main.get_green(), 'green') 8 | 9 | 10 | if __name__ == '__main__': 11 | unittest.main() 12 | -------------------------------------------------------------------------------- /php/with-atoum/README.md: -------------------------------------------------------------------------------- 1 | # PHP kata starter 2 | 3 | ## Install 4 | ```bash 5 | composer install 6 | ``` 7 | 8 | ## Testing tool 9 | [Atoum](http://docs.atoum.org) 10 | 11 | 12 | Then, to run the tests 13 | ```bash 14 | ./vendor/bin/atoum -d ./tests 15 | ``` 16 | -------------------------------------------------------------------------------- /go/simple.go: -------------------------------------------------------------------------------- 1 | package kata 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // Simple main function 9 | func Simple(number int, msg string) string { 10 | fmt.Printf("Kata number: %d, msg: %s\n", number, msg) 11 | return "result: " + strconv.Itoa(number) + msg 12 | } 13 | -------------------------------------------------------------------------------- /groovy/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 17 21:40:07 CET 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip 7 | -------------------------------------------------------------------------------- /js/with-jest/jest/__tests__/sum.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | jest.dontMock('../lib/sum.js'); 4 | 5 | const sum = require('../lib/sum.js'); 6 | 7 | describe('Sum numbers', () => { 8 | 9 | it('adds 1 + 2 to equal 3', () => { 10 | expect(sum(1, 2)).toBe(3); 11 | }); 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /java/java-graddle/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 25 23:59:50 CET 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip 7 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/__tests__/sum.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | jest.dontMock('../lib/sum.js'); 4 | 5 | const sum = require('../lib/sum.js'); 6 | 7 | describe('Sum numbers', () => { 8 | 9 | it('adds 1 + 2 to equal 3', () => { 10 | expect(sum(1, 2)).toBe(3); 11 | }); 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /cpp/cmake/tests/unit_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) 2 | 3 | add_executable(Unit_Tests_run 4 | test_fizz_buzz.cpp 5 | ) 6 | 7 | target_link_libraries(Unit_Tests_run gtest gtest_main) 8 | target_link_libraries(Unit_Tests_run ${CMAKE_PROJECT_NAME}_lib) -------------------------------------------------------------------------------- /scala/src/test/scala/com/dojo/kata/Kata1Test.scala: -------------------------------------------------------------------------------- 1 | package com.dojo.kata 2 | 3 | import org.scalatest._ 4 | 5 | class Kata1Test extends FlatSpec with Matchers { 6 | 7 | it should "foo" in { 8 | val kata = new Kata("todo") 9 | kata.name should equal ("fixme") 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /java/java-maven/.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Java - Maven 3 | ###################### 4 | 5 | target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | -------------------------------------------------------------------------------- /php/with-phpspec/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [Makefile] 12 | indent_style = tab 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /php/with-phpunit/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [Makefile] 12 | indent_style = tab 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /php/with-phpspec-offline/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [Makefile] 12 | indent_style = tab 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma-babel/src/Song.js: -------------------------------------------------------------------------------- 1 | class Song { 2 | 3 | persistFavoriteStatus(value) { 4 | // something complicated 5 | throw new Error("not yet implemented"); 6 | } 7 | 8 | } 9 | 10 | // FIXME je n'arrive pas à faire fonctionner `exports` voir commonjs ( browserify/webpack etc) 11 | //export default Song; 12 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-babel/src/song.js: -------------------------------------------------------------------------------- 1 | class Song { 2 | 3 | persistFavoriteStatus(value) { 4 | // something complicated 5 | throw new Error('not yet implemented'); 6 | } 7 | 8 | } 9 | 10 | // FIXME je n'arrive pas à faire fonctionner `exports` voir commonjs ( browserify/webpack etc) 11 | //export default Song; 12 | -------------------------------------------------------------------------------- /scala/readme.md: -------------------------------------------------------------------------------- 1 | # Kata Template Scala 2 | 3 | 4 | ## SBT 5 | 6 | Lancer les tests : 7 | 8 | ```shell 9 | sbt test 10 | ``` 11 | 12 | Lancer les tests en continue dès qu'un fichier est modifié : 13 | 14 | ```shell 15 | sbt 16 | ~test 17 | ``` 18 | 19 | 20 | ## References 21 | 22 | - [ScalaTest](http://www.scalatest.org) 23 | 24 | -------------------------------------------------------------------------------- /scala/.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Scala 3 | ###################### 4 | 5 | *.class 6 | *.log 7 | 8 | # sbt specific 9 | .cache 10 | .history 11 | .lib/ 12 | dist/* 13 | target/ 14 | lib_managed/ 15 | src_managed/ 16 | project/boot/ 17 | project/plugins/project/ 18 | 19 | # Scala-IDE specific 20 | .scala_dependencies 21 | .worksheet 22 | -------------------------------------------------------------------------------- /scala/src/test/scala/com/dojo/kata/Kata2Test.scala: -------------------------------------------------------------------------------- 1 | package com.dojo.kata 2 | 3 | import org.scalatest.{ShouldMatchers, FunSuite} 4 | 5 | class Kata2Test extends FunSuite with ShouldMatchers { 6 | 7 | test("1 should equal to 2") { 8 | val kata = new Kata("todo") 9 | kata.name should equal ("fixme") 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /php/with-atoum/src/Domain/User/UserRepositoryInterface.php: -------------------------------------------------------------------------------- 1 | 3 | console.log "Instantiated new Calculator instance" 4 | 5 | add: (num1, num2) -> 6 | num1 + num2 7 | 8 | subtract: (num1, num2) -> 9 | num1 - num2 10 | 11 | multiply: (num1, num2) -> 12 | num1 * num2 13 | 14 | divide: (num1, num2) -> 15 | num1/num2 16 | -------------------------------------------------------------------------------- /js/with-jest/jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-jest-project", 3 | "version": "1.0.0", 4 | "description": "My jest project", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "keywords": [ 10 | "project", 11 | "jest" 12 | ], 13 | "author": "ldez", 14 | "license": "ISC", 15 | "devDependencies": { 16 | "jest": "^17.0.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cpp/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | project(FizzBuzz) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | set(SOURCE_FILES main.cpp) 7 | add_executable(${CMAKE_PROJECT_NAME}_run ${SOURCE_FILES}) 8 | 9 | include_directories(src) 10 | 11 | add_subdirectory(src) 12 | add_subdirectory(tests) 13 | 14 | target_link_libraries(${CMAKE_PROJECT_NAME}_run ${CMAKE_PROJECT_NAME}_lib) 15 | 16 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/spec/helper/spec-helper.coffee: -------------------------------------------------------------------------------- 1 | beforeEach -> 2 | matcher = 3 | toBePlaying: -> 4 | return { 5 | compare: (actual, expected) -> 6 | player = actual 7 | 8 | return { 9 | pass: player.currentlyPlayingSong == expected and player.isPlaying 10 | } 11 | } 12 | jasmine.addMatchers(matcher) 13 | 14 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-jasmine-project", 3 | "version": "1.0.0", 4 | "description": "My jasmine project", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jasmine" 8 | }, 9 | "keywords": [ 10 | "project", 11 | "jasmine" 12 | ], 13 | "author": "ldez", 14 | "license": "ISC", 15 | "devDependencies": { 16 | "jasmine": "^2.3.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /groovy/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | 4 | # Ignore Gradle GUI config 5 | gradle-app.setting 6 | 7 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 8 | !gradle-wrapper.jar 9 | 10 | # Cache of project 11 | .gradletasknamecache 12 | 13 | # IDEA 14 | *.iml 15 | .idea 16 | 17 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 18 | # gradle/wrapper/gradle-wrapper.properties 19 | -------------------------------------------------------------------------------- /php/with-phpspec/README.md: -------------------------------------------------------------------------------- 1 | # PHP kata starter 2 | 3 | ## Install 4 | ```bash 5 | composer install 6 | ``` 7 | 8 | ## Testing tool 9 | [PhpSpec](https://phpspec.readthedocs.io) 10 | 11 | Every time you need to create a test (spec) 12 | ```bash 13 | vendor/bin/phpspec describe 'Kata' 14 | ``` 15 | 16 | Then, to run the tests 17 | ```bash 18 | vendor/bin/phpspec run 19 | ``` 20 | or 21 | ```bash 22 | make tests 23 | ``` 24 | -------------------------------------------------------------------------------- /php/with-phpspec-offline/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env make -f 2 | 3 | .DEFAULT_GOAL := help 4 | 5 | # This prevents make from being confused by a file with the same name as the phony target. 6 | .PHONY: help tests 7 | 8 | help: 9 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 10 | 11 | tests: ## run phpspec 12 | php phpspec.phar run 13 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/src/Player.coffee: -------------------------------------------------------------------------------- 1 | class Player 2 | 3 | play: (song) -> 4 | @currentlyPlayingSong = song 5 | @isPlaying = true 6 | 7 | pause: -> 8 | @isPlaying = false 9 | 10 | resume: -> 11 | if @isPlaying 12 | throw new Error('song is already playing') 13 | 14 | @isPlaying = true 15 | 16 | makeFavorite: -> 17 | @currentlyPlayingSong.persistFavoriteStatus(true) 18 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/spec/SpecHelper.js: -------------------------------------------------------------------------------- 1 | beforeEach(function () { 2 | jasmine.addMatchers({ 3 | toBePlaying: function () { 4 | return { 5 | compare: function (actual, expected) { 6 | var player = actual; 7 | 8 | return { 9 | pass: player.currentlyPlayingSong === expected && player.isPlaying 10 | }; 11 | } 12 | }; 13 | } 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /php/with-phpunit/tests/DummyTest.php: -------------------------------------------------------------------------------- 1 | returnFalse()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-htmlrunner/TestRunner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | QUnit Example 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-babel/spec/spec-helper.js: -------------------------------------------------------------------------------- 1 | beforeEach(() => { 2 | 'use strict'; 3 | 4 | jasmine.addMatchers({ 5 | toBePlaying: () => { 6 | return { 7 | compare: (actual, expected) => { 8 | let player = actual; 9 | 10 | return { 11 | pass: player.currentlyPlayingSong === expected && player.isPlaying 12 | }; 13 | } 14 | }; 15 | } 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/spec/helpers/jasmine_examples/SpecHelper.js: -------------------------------------------------------------------------------- 1 | beforeEach(function () { 2 | jasmine.addMatchers({ 3 | toBePlaying: function () { 4 | return { 5 | compare: function (actual, expected) { 6 | var player = actual; 7 | 8 | return { 9 | pass: player.currentlyPlayingSong === expected && player.isPlaying 10 | }; 11 | } 12 | }; 13 | } 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /cpp/cmake/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(${CMAKE_PROJECT_NAME}_tests) 2 | 3 | # Clone Google Test 4 | set(GOOGLETEST_DIR ${CMAKE_SOURCE_DIR}/tests/lib/googletest) 5 | if(NOT EXISTS ${GOOGLETEST_DIR}) 6 | find_package(Git REQUIRED) 7 | execute_process( 8 | COMMAND ${GIT_EXECUTABLE} clone https://github.com/google/googletest ${GOOGLETEST_DIR} 9 | ) 10 | endif() 11 | 12 | add_subdirectory(lib/googletest) 13 | add_subdirectory(unit_tests) -------------------------------------------------------------------------------- /go/.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Go 3 | ###################### 4 | 5 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 6 | *.o 7 | *.a 8 | *.so 9 | 10 | # Folders 11 | _obj 12 | _test 13 | 14 | # Architecture specific extensions/prefixes 15 | *.[568vq] 16 | [568vq].out 17 | 18 | *.cgo1.go 19 | *.cgo2.c 20 | _cgo_defun.c 21 | _cgo_gotypes.go 22 | _cgo_export.* 23 | 24 | _testmain.go 25 | 26 | *.exe 27 | *.test 28 | *.prof 29 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/spec/helpers/jasmine_examples/SpecHelper.js: -------------------------------------------------------------------------------- 1 | beforeEach(function () { 2 | jasmine.addMatchers({ 3 | toBePlaying: function () { 4 | return { 5 | compare: function (actual, expected) { 6 | var player = actual; 7 | 8 | return { 9 | pass: player.currentlyPlayingSong === expected && player.isPlaying 10 | }; 11 | } 12 | }; 13 | } 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.{java,php,xml}] 12 | indent_size = 4 13 | 14 | [*.{js,css,yml}] 15 | indent_size = 2 16 | 17 | [*.sh] 18 | indent_size = 2 19 | 20 | [*.md] 21 | trim_trailing_whitespace = false 22 | indent_size = 2 23 | 24 | [*.go] 25 | indent_style = tab 26 | indent_size = 4 27 | 28 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-typescript/spec/hello-world.test.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | describe("HelloWorld:", () => { 5 | 6 | var world :HelloWorld; 7 | 8 | beforeEach(() => { 9 | world = new HelloWorld("John"); 10 | }); 11 | 12 | it("should pass a simple test", () => { 13 | expect(world.hello()).toEqual("Hello John"); 14 | }); 15 | 16 | }); 17 | -------------------------------------------------------------------------------- /js/with-mocha/mocha/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-mocha-project", 3 | "version": "1.0.0", 4 | "description": "My mocha project", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha test" 8 | }, 9 | "keywords": [ 10 | "project", 11 | "mocha" 12 | ], 13 | "author": "ldez", 14 | "license": "ISC", 15 | "devDependencies": { 16 | "chai": "^3.3.0", 17 | "mocha": "^2.3.3", 18 | "sinon": "^1.17.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /cpp/cmake/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(${CMAKE_PROJECT_NAME}_lib) 2 | 3 | set(HEADER_FILES 4 | ) 5 | set(SOURCE_FILES 6 | fizz_buzz.cpp) 7 | 8 | if (EXISTS ${SOURCE_FILES}) 9 | # The library contains header and source files. 10 | add_library(${CMAKE_PROJECT_NAME}_lib STATIC 11 | ${SOURCE_FILES} 12 | ${HEADER_FILES} 13 | ) 14 | else() 15 | # The library only contains header files. 16 | add_library(${CMAKE_PROJECT_NAME}_lib INTERFACE) 17 | endif() -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/src/Player.js: -------------------------------------------------------------------------------- 1 | export default class Player { 2 | 3 | play(song) { 4 | this.currentlyPlayingSong = song; 5 | this.isPlaying = true; 6 | } 7 | pause() { 8 | this.isPlaying = false; 9 | } 10 | 11 | resume() { 12 | if (this.isPlaying) { 13 | throw new Error('song is already playing'); 14 | } 15 | 16 | this.isPlaying = true; 17 | } 18 | 19 | makeFavorite() { 20 | this.currentlyPlayingSong.persistFavoriteStatus(true); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /php/with-phpunit/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env make -f 2 | 3 | .DEFAULT_GOAL := help 4 | 5 | # This prevents make from being confused by a file with the same name as the phony target. 6 | .PHONY: help tests 7 | 8 | help: 9 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 10 | 11 | VENDOR_BIN := vendor/bin 12 | 13 | tests: ## run phpunit if available in vendor/bin 14 | @[ -x $(VENDOR_BIN)/phpunit ] && $(VENDOR_BIN)/phpunit 15 | -------------------------------------------------------------------------------- /php/with-atoum/src/Domain/User/UserId.php: -------------------------------------------------------------------------------- 1 | id = $id; 19 | } 20 | 21 | /** 22 | * @return integer 23 | */ 24 | public function getId() 25 | { 26 | return $this->id; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /php/with-phpspec/Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env make -f 2 | 3 | .DEFAULT_GOAL := help 4 | 5 | # This prevents make from being confused by a file with the same name as the phony target. 6 | .PHONY: help tests 7 | 8 | help: 9 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 10 | 11 | VENDOR_BIN := vendor/bin 12 | 13 | tests: ## run phpspec if available in vendor/bin 14 | @[ -x $(VENDOR_BIN)/phpspec ] && $(VENDOR_BIN)/phpspec run 15 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-jest-project", 3 | "version": "1.0.0", 4 | "description": "My jest project", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest" 8 | }, 9 | "keywords": [ 10 | "project", 11 | "jest", 12 | "babel" 13 | ], 14 | "author": "ldez", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "babel-jest": "^17.0.2", 18 | "babel-polyfill": "^6.20.0", 19 | "babel-preset-es2015": "^6.18.0", 20 | "jest": "^17.0.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /php/with-atoum/src/Domain/User/User.php: -------------------------------------------------------------------------------- 1 | userId = $userId; 19 | } 20 | 21 | /** 22 | * @return UserId 23 | */ 24 | public function getUserId() 25 | { 26 | return $this->userId; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-mocha-project", 3 | "version": "1.0.0", 4 | "description": "My mocha project", 5 | "main": "index.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "mocha --compilers js:babel/register" 11 | }, 12 | "keywords": [ 13 | "project", 14 | "babel", 15 | "mocha" 16 | ], 17 | "author": "ldez", 18 | "license": "ISC", 19 | "devDependencies": { 20 | "chai": "^3.3.0", 21 | "mocha": "^2.3.3", 22 | "sinon": "^1.17.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /php/with-atoum/tests/Domain/User/UserId.php: -------------------------------------------------------------------------------- 1 | testedClass 13 | ->hasMethod('getId'); 14 | } 15 | 16 | public function testInstance() 17 | { 18 | $this 19 | ->object($this->newTestedInstance(1234)) 20 | ->integer($this->testedInstance->getId()) 21 | ->isEqualTo(1234); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # All 3 | ###################### 4 | tmp 5 | 6 | 7 | ###################### 8 | # Eclipse 9 | ###################### 10 | .classpath 11 | .project 12 | .settings 13 | 14 | 15 | ###################### 16 | # IntelliJ 17 | ###################### 18 | .idea 19 | *.iml 20 | *.iws 21 | *.ipr 22 | *.ids 23 | 24 | 25 | ###################### 26 | # Windows 27 | ###################### 28 | # Windows image file caches 29 | Thumbs.db 30 | 31 | 32 | ###################### 33 | # SASS 34 | ###################### 35 | .sass-cache/ 36 | *.css.map 37 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/src/Player.js: -------------------------------------------------------------------------------- 1 | function Player() { 2 | } 3 | Player.prototype.play = function(song) { 4 | this.currentlyPlayingSong = song; 5 | this.isPlaying = true; 6 | }; 7 | 8 | Player.prototype.pause = function() { 9 | this.isPlaying = false; 10 | }; 11 | 12 | Player.prototype.resume = function() { 13 | if (this.isPlaying) { 14 | throw new Error("song is already playing"); 15 | } 16 | 17 | this.isPlaying = true; 18 | }; 19 | 20 | Player.prototype.makeFavorite = function() { 21 | this.currentlyPlayingSong.persistFavoriteStatus(true); 22 | }; -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-jest/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-mocha/mocha/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/src/jasmine_examples/Player.js: -------------------------------------------------------------------------------- 1 | function Player() {} 2 | 3 | Player.prototype.play = function (song) { 4 | this.currentlyPlayingSong = song; 5 | this.isPlaying = true; 6 | }; 7 | 8 | Player.prototype.pause = function () { 9 | this.isPlaying = false; 10 | }; 11 | 12 | Player.prototype.resume = function () { 13 | if (this.isPlaying) { 14 | throw new Error('song is already playing'); 15 | } 16 | 17 | this.isPlaying = true; 18 | }; 19 | 20 | Player.prototype.makeFavorite = function () { 21 | this.currentlyPlayingSong.persistFavoriteStatus(true); 22 | }; 23 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-karma/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{*.json,*.js,*.html,*.css,*.coffee}] 23 | indent_size = 2 24 | -------------------------------------------------------------------------------- /php/with-atoum/.bootstrap.atoum.php: -------------------------------------------------------------------------------- 1 | 2 | calc = {} 3 | beforeEach -> 4 | calc = new Calculator() 5 | 6 | it 'should be able to add two numbers', () -> 7 | expect(calc.add 3,4 ).toBe 7 8 | 9 | it 'should be able to subtract two numbers', () -> 10 | expect(calc.subtract 32,18 ).toBe 14 11 | 12 | it 'should be able to multiply two numbers', () -> 13 | expect(calc.multiply 6,4 ).toBe 24 14 | 15 | it 'should be able to divide two numbers', () -> 16 | expect(calc.divide 32,8 ).toBe 4 17 | 18 | it 'should be able to divide to zero and receive Infinity', () -> 19 | expect(calc.divide 32,0 ).toBe Infinity 20 | 21 | it 'should be able to divide to Infinity and receive zero', () -> 22 | expect(calc.divide 32,Infinity ).toBe 0 23 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma-babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-mocha-project", 3 | "version": "1.0.0", 4 | "description": "My mocha project", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha test" 8 | }, 9 | "keywords": [ 10 | "project", 11 | "mocha", 12 | "karma", 13 | "babel" 14 | ], 15 | "author": "ldez", 16 | "license": "ISC", 17 | "devDependencies": { 18 | "chai": "^3.3.0", 19 | "isparta": "^3.1.0", 20 | "karma": "^0.13.11", 21 | "karma-babel-preprocessor": "^5.2.2", 22 | "karma-chai": "^0.1.0", 23 | "karma-coverage": "^0.5.2", 24 | "karma-mocha": "^0.2.0", 25 | "karma-phantomjs-launcher": "^0.2.1", 26 | "karma-sinon": "^1.0.4", 27 | "mocha": "^2.3.3", 28 | "phantomjs": "^1.9.18", 29 | "sinon": "^1.17.1" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-karma/test/sample.test.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | QUnit.module('module A', { 5 | beforeEach: function () { 6 | // prepare something for all following tests 7 | }, 8 | afterEach: function () { 9 | // clean up after each test 10 | } 11 | }); 12 | 13 | QUnit.test('a basic test example', function (assert) { 14 | assert.ok(true, 'this test is fine'); 15 | }); 16 | QUnit.test('a basic test example 2', function (assert) { 17 | assert.ok(true, 'this test is fine'); 18 | }); 19 | 20 | QUnit.module('group b'); 21 | 22 | QUnit.test('a basic test example 3', function (assert) { 23 | assert.ok(true, 'this test is fine'); 24 | }); 25 | QUnit.test('a basic test example 4', function (assert) { 26 | assert.ok(true, 'this test is fine'); 27 | }); 28 | 29 | })(); 30 | -------------------------------------------------------------------------------- /php/with-atoum/tests/Domain/User/User.php: -------------------------------------------------------------------------------- 1 | testedClass 14 | ->hasMethod('getUserId'); 15 | } 16 | 17 | public function testInstance() 18 | { 19 | $this 20 | ->assert('Test create new instance and getter of userId') 21 | ->given( 22 | $mockUserId = new \mock\KataStarter\WithAtoum\Domain\User\UserId(1234), 23 | $this->newTestedInstance($mockUserId) 24 | ) 25 | ->object($this->testedInstance->getUserId()) 26 | ->isInstanceOf(UserId::class) 27 | ; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/SpecRunner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jasmine Spec Runner v2.3.4 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Jasmine & HTML Runner 2 | 3 | 4 | ## HTML Runner 5 | 6 | - [jasmine-standalone-x.x.x.zip](https://github.com/jasmine/jasmine/releases) 7 | - Unzip `jasmine-standalone-x.x.x.zip` 8 | 9 | 10 | ## Run tests 11 | 12 | Open `SpecRunner.html` file in your browser. 13 | 14 | 15 | ## Project structure 16 | 17 | ``` 18 | ├── lib 19 | │ ├── jasmine-x.x.x 20 | │ │ ├── boot.js 21 | │ │ ├── console.js 22 | │ │ ├── jasmine-html.js 23 | │ │ ├── jasmine.css 24 | │ │ ├── jasmine.js 25 | │ │ └── jasmine_favicon.png 26 | │ └── ... 27 | ├── src 28 | │ ├── file01.js 29 | │ ├── file02.js 30 | │ └── ... 31 | ├── spec 32 | │ ├── file01.spec.js 33 | │ ├── file02.spec.js 34 | │ └── ... 35 | ├── SpecRunner.html 36 | ├── MIT.LICENSE 37 | ├── package.json 38 | ├── karma.conf.js 39 | ├── .editorconfig 40 | └── .jshintrc 41 | ``` 42 | -------------------------------------------------------------------------------- /groovy/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.dojo' 2 | version '1.0.0-SNAPSHOT' 3 | 4 | apply plugin: 'groovy' 5 | apply plugin: 'java' 6 | apply plugin: 'codenarc' 7 | 8 | sourceCompatibility = 1.8 9 | 10 | repositories { 11 | mavenLocal() 12 | mavenCentral() 13 | jcenter() 14 | } 15 | 16 | dependencies { 17 | compile 'org.codehaus.groovy:groovy-all:2.4.6' 18 | testCompile group: 'junit', name: 'junit', version: '4.12' 19 | testCompile('org.spockframework:spock-core:1.0-groovy-2.4') { 20 | exclude module: 'groovy-all' 21 | } 22 | testCompile 'cglib:cglib-nodep:2.2.2' // used by Spock 23 | } 24 | 25 | codenarc { 26 | toolVersion = '0.24' 27 | configFile = file('config/codenarc/rules.groovy') 28 | } 29 | 30 | codenarcTest { 31 | configFile = file('config/codenarc/rules-test.groovy') 32 | } 33 | 34 | task wrapper(type: Wrapper) { 35 | gradleVersion = '2.11' 36 | } 37 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | ###################### 2 | # Python 3 | ###################### 4 | 5 | # Byte-compiled / optimized / DLL files 6 | __pycache__/ 7 | *.py[cod] 8 | *$py.class 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Distribution / packaging 14 | .Python 15 | env/ 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *,cover 50 | 51 | # Translations 52 | *.mo 53 | *.pot 54 | 55 | # Django stuff: 56 | *.log 57 | 58 | # Sphinx documentation 59 | docs/_build/ 60 | 61 | # PyBuilder 62 | target/ 63 | -------------------------------------------------------------------------------- /groovy/config/codenarc/rules-test.groovy: -------------------------------------------------------------------------------- 1 | ruleset { 2 | ruleset('rulesets/junit.xml') { 3 | // Spock ... 4 | exclude 'JUnitPublicNonTestMethod' 5 | } 6 | 7 | ruleset('file:config/codenarc/rules.groovy') { 8 | 9 | // that's OK for test code 10 | exclude 'ClassJavadoc' 11 | // that's OK for test code 12 | exclude 'ComparisonWithSelf' 13 | // that's OK for test code 14 | exclude 'ExplicitCallToCompareToMethod' 15 | // that's OK for test code 16 | exclude 'ExplicitCallToEqualsMethod' 17 | // Spock encourages to violate this rule 18 | exclude 'MethodName' 19 | // that's OK for test code 20 | exclude 'NoDef' 21 | // Fields annotated with @org.junit.Rule violate this rule 22 | exclude 'NonFinalPublicField' 23 | // Fields annotated with @org.junit.Rule violate this rule 24 | exclude 'PublicInstanceField' 25 | // Spock's data tables violate this rule 26 | exclude 'UnnecessaryBooleanExpression' 27 | // causes false negatives 28 | // exclude 'UnusedObject' 29 | } 30 | } -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/MIT.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2014 Pivotal Labs 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /php/with-atoum/src/Infrastructure/User/UserRepository.php: -------------------------------------------------------------------------------- 1 | provider = $provider; 25 | } 26 | 27 | /** 28 | * @param UserId $userId 29 | * @return User 30 | * @throws UserException 31 | */ 32 | public function getById(UserId $userId) 33 | { 34 | $key = $userId->getId(); 35 | if (!$this->provider->has($key)) { 36 | throw new UserException(sprintf('User with id "%s" doesn\'t exists !', $key)); 37 | } 38 | 39 | return $this->provider->get($key); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /go/simple_test.go: -------------------------------------------------------------------------------- 1 | package kata 2 | 3 | import "testing" 4 | 5 | func Test_simple(t *testing.T) { 6 | 7 | rt := Simple(1, "foo") 8 | 9 | if rt != "result: 1foo" { 10 | t.Errorf("Must de %s but was %s", "result: 1foo", rt) 11 | } 12 | } 13 | 14 | type data struct { 15 | number int 16 | msg, out string 17 | } 18 | 19 | var testDatas = []data{ 20 | data{1, "foo", "result: 1foo"}, 21 | data{2, "bar", "result: 2bar"}, 22 | data{3, "bir", "result: 3bir"}, 23 | data{4, "bor", "result: 4bor"}, 24 | data{5, "bur", "result: 5bur"}, 25 | } 26 | 27 | func Test_simple_struct(t *testing.T) { 28 | 29 | for _, test := range testDatas { 30 | out := Simple(test.number, test.msg) 31 | if out != test.out { 32 | t.Errorf("Simple(%v, %v) = %v, want %v", test.number, test.msg, out, test.out) 33 | } 34 | } 35 | } 36 | 37 | func Test_simple_inner_struct(t *testing.T) { 38 | for _, test := range []struct { 39 | number int 40 | msg, out string 41 | }{ 42 | {1, "foo", "result: 1foo"}, 43 | {2, "bar", "result: 2bar"}, 44 | {3, "bir", "result: 3bir"}, 45 | {4, "bor", "result: 4bor"}, 46 | {5, "bur", "result: 5bur"}, 47 | } { 48 | out := Simple(test.number, test.msg) 49 | if out != test.out { 50 | t.Errorf("Simple(%v, %v) = %v, want %v", test.number, test.msg, out, test.out) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma/test/sample.test.js: -------------------------------------------------------------------------------- 1 | describe('Array', function () { 2 | 'use strict'; 3 | 4 | describe('#push()', function () { 5 | it('should append a value', function () { 6 | var arr = []; 7 | arr.push('foo'); 8 | arr.push('bar'); 9 | arr.push('baz'); 10 | 11 | assert.equal('foo', arr[0]); 12 | assert.equal('bar', arr[1]); 13 | assert.equal('baz', arr[2]); 14 | 15 | assert('foo' === arr[0]); 16 | assert('bar' === arr[1]); 17 | assert('baz' === arr[2]); 18 | }); 19 | 20 | it('should return the length', function () { 21 | var arr = []; 22 | 23 | assert.equal(1, arr.push('foo')); 24 | assert.equal(2, arr.push('bar')); 25 | assert.equal(3, arr.push('baz')); 26 | }); 27 | }); 28 | }); 29 | 30 | describe('Array', function () { 31 | 'use strict'; 32 | 33 | describe('#pop()', function () { 34 | it('should remove and return the last value', function () { 35 | var arr = [1, 2, 3]; 36 | 37 | assert.equal(3, arr.pop()); 38 | assert.equal(2, arr.pop()); 39 | assert.equal(1, arr.pop()); 40 | }); 41 | 42 | it('should adjust .length', function () { 43 | var arr = [1, 2, 3]; 44 | arr.pop(); 45 | 46 | assert.equal(2, arr.length); 47 | }); 48 | }); 49 | 50 | }); 51 | -------------------------------------------------------------------------------- /js/with-mocha/mocha/test/sample.test.js: -------------------------------------------------------------------------------- 1 | var assert = require("assert"); 2 | // Chai 3 | var chai = require("chai"); 4 | // Sinon.js 5 | var sinon = require("sinon"); 6 | 7 | describe('Array', function () { 8 | 'use strict'; 9 | 10 | describe('#push()', function () { 11 | it('should append a value', function () { 12 | var arr = []; 13 | arr.push('foo'); 14 | arr.push('bar'); 15 | arr.push('baz'); 16 | 17 | assert.equal('foo', arr[0]); 18 | assert.equal('bar', arr[1]); 19 | assert.equal('baz', arr[2]); 20 | 21 | assert('foo' === arr[0]); 22 | assert('bar' === arr[1]); 23 | assert('baz' === arr[2]); 24 | }); 25 | 26 | it('should return the length', function () { 27 | var arr = []; 28 | 29 | assert.equal(1, arr.push('foo')); 30 | assert.equal(2, arr.push('bar')); 31 | assert.equal(3, arr.push('baz')); 32 | }); 33 | }); 34 | }); 35 | 36 | describe('Array', function () { 37 | 'use strict'; 38 | 39 | describe('#pop()', function () { 40 | it('should remove and return the last value', function () { 41 | var arr = [1, 2, 3]; 42 | 43 | assert.equal(3, arr.pop()); 44 | assert.equal(2, arr.pop()); 45 | assert.equal(1, arr.pop()); 46 | }); 47 | 48 | it('should adjust .length', function () { 49 | var arr = [1, 2, 3]; 50 | arr.pop(); 51 | 52 | assert.equal(2, arr.length); 53 | }); 54 | }); 55 | 56 | }); 57 | -------------------------------------------------------------------------------- /cpp/cmake/README.md: -------------------------------------------------------------------------------- 1 | # C++ - CMake 2 | 3 | ## Instructions to Run on Ubuntu 4 | 5 | First of all, you need to generate the makefiles with CMake 6 | 7 | ``` 8 | $> sudo apt-get install cmake 9 | $> cd /path/to/FizzBuzz 10 | $> mkdir Debug && cd Debug 11 | $> cmake -DCMAKE_BUILD_TYPE=Debug .. 12 | $> cd .. 13 | ``` 14 | 15 | After that, you can build the project any time you make a modification 16 | 17 | ``` 18 | $> cmake --build Debug/ --target all 19 | ``` 20 | 21 | Tests can be ran using the generated executable 22 | 23 | ``` 24 | $> ./Debug/tests/unit_tests/Unit_Tests_run 25 | ``` 26 | 27 | ## Test Tooling 28 | 29 | - https://github.com/google/googletest 30 | 31 | ## CLion IDE Specific Instructions 32 | 33 | 1. The IDE allows you to mark directories with their desired purpose. 34 | To mark a directory right click on the directory name in the `Project` window 35 | and select `Mark Directory as` from the drop-down menu. 36 | 1. Mark the `src` directory as `Project Sources and Headers` 37 | 1. Mark the `tests/lib/googletest` directory as `Library Files` 38 | 1. Setup the `Run/Debug Configuration` by selecting `Edit Configurations...` 39 | from the pull-down menu from the run button (green triangle) in the upper right 40 | corner. 41 | 1. Create a `Google Test` configuration 42 | 1. In the upper left corner select the plus symbol. 43 | 1. Chose `Google Test` from the drop-down menu. 44 | 1. Set **Name** to `Unit Tests`. 45 | 1. Set **Target** to `Unit_Tests_run`. 46 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/spec/player.spec.coffee: -------------------------------------------------------------------------------- 1 | describe 'Calculator', () -> 2 | player = null 3 | song = null 4 | 5 | beforeEach -> 6 | player = new Player 7 | song = new Song 8 | 9 | it 'should be able to play a Song', () -> 10 | player.play song 11 | 12 | expect(player.currentlyPlayingSong).toEqual song 13 | 14 | # demonstrates use of custom matcher 15 | expect(player).toBePlaying song 16 | 17 | describe 'when song has been paused', () -> 18 | beforeEach -> 19 | player.play song 20 | player.pause() 21 | 22 | it 'should indicate that the song is currently paused', () -> 23 | expect(player.isPlaying).toBeFalsy() 24 | 25 | # demonstrates use of 'not' with a custom matcher 26 | expect(player).not.toBePlaying song 27 | 28 | it 'should be possible to resume', () -> 29 | player.resume() 30 | expect(player.isPlaying).toBeTruthy() 31 | expect(player.currentlyPlayingSong).toEqual song 32 | 33 | # demonstrates use of spies to intercept and test method calls 34 | it 'tells the current song if the user has made it a favorite', () -> 35 | spyOn song, 'persistFavoriteStatus' 36 | 37 | player.play song 38 | player.makeFavorite() 39 | 40 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith true 41 | 42 | # demonstrates use of expected exceptions 43 | describe '#resume', () -> 44 | it 'should throw an exception if song is already playing', () -> 45 | player.play song 46 | 47 | expect () -> 48 | player.resume() 49 | .toThrowError 'song is already playing' 50 | -------------------------------------------------------------------------------- /go/readme.md: -------------------------------------------------------------------------------- 1 | # Go 2 | 3 | ## References 4 | 5 | - https://golang.org 6 | - Download: https://golang.org/dl 7 | - Documentation: https://golang.org/doc 8 | - https://golang.org/doc/effective_go.html 9 | - https://golang.org/ref/spec 10 | - https://github.com/a8m/go-lang-cheat-sheet 11 | 12 | ## IDE 13 | 14 | - https://github.com/golang/go/wiki/IDEsAndTextEditorPlugins 15 | - Autocomplete dans les IDE : [Gocode](https://github.com/nsf/gocode) 16 | 17 | ## Articles 18 | 19 | - http://decouvrir-golang.net/ 20 | - http://golang-examples.tumblr.com 21 | - http://www.golangpatterns.info/object-oriented/operators 22 | - http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 23 | - Un bon article sur la gestion des erreurs en Go. Utile lorsqu'on ne connaît que les exceptions ! : https://justinas.org/best-practices-for-errors-in-go/ 24 | - http://miek.nl/go/learninggo.html#beyond-the-basics 25 | - http://etienner.fr/golang/creer-une-api-restfull-sur-go 26 | 27 | ## Resources 28 | 29 | - https://gobyexample.com/ 30 | - https://github.com/golang/example 31 | - https://github.com/golang-samples 32 | - https://github.com/gobridge 33 | 34 | ## Testing 35 | 36 | - http://golang.org/pkg/testing 37 | - https://github.com/golang-samples/testing 38 | 39 | Les méthodes de test doivent commencer par `Test`. 40 | 41 | ```go 42 | import "testing" 43 | 44 | func TestName(t *testing.T) { 45 | [...] 46 | if actual != expected { 47 | t.Errorf("Must be %s but was %s", expected, actual) 48 | } 49 | } 50 | ``` 51 | 52 | ## Test Tooling 53 | 54 | - https://github.com/stretchr/testify 55 | - http://goconvey.co 56 | - https://labix.org/gocheck 57 | 58 | 59 | -------------------------------------------------------------------------------- /js/with-jest/jest/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Jest project 2 | 3 | - https://facebook.github.io/jest/ 4 | 5 | 6 | ## Initiate NPM project 7 | 8 | ```shell 9 | npm init 10 | ``` 11 | 12 | Console output: 13 | 14 | ```shell 15 | This utility will walk you through creating a package.json file. 16 | It only covers the most common items, and tries to guess sensible defaults. 17 | 18 | See `npm help json` for definitive documentation on these fields 19 | and exactly what they do. 20 | 21 | Use `npm install --save` afterwards to install a package and 22 | save it as a dependency in the package.json file. 23 | 24 | Press ^C at any time to quit. 25 | name: (temp) my-jest-project 26 | version: (1.0.0) 27 | description: My jest project 28 | entry point: (index.js) 29 | test command: jest 30 | git repository: 31 | keywords: project, jest 32 | author: you 33 | license: (ISC) 34 | About to write to ...\package.json: 35 | 36 | { 37 | "name": "my-jest-project", 38 | "version": "1.0.0", 39 | "description": "My jest project", 40 | "main": "index.js", 41 | "scripts": { 42 | "test": "jest" 43 | }, 44 | "keywords": [ 45 | "project", 46 | "jest" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Jest 57 | 58 | ```shell 59 | npm install -D jest 60 | ``` 61 | 62 | ## Run tests 63 | 64 | ```shell 65 | npm test 66 | ``` 67 | 68 | 69 | ## Project structure 70 | 71 | ``` 72 | ├── __tests__ 73 | │ ├── file01.js 74 | │ ├── file02.js 75 | │ └── ... 76 | ├── spec 77 | │ ├── file01.spec.js 78 | │ ├── file02.spec.js 79 | │ ├── file03.test.js 80 | │ └── ... 81 | ├── package.json 82 | ├── .editorconfig 83 | └── .jshintrc 84 | ``` 85 | -------------------------------------------------------------------------------- /php/with-atoum/src/Infrastructure/Provider/ArrayDataProvider.php: -------------------------------------------------------------------------------- 1 | data = $data; 22 | } 23 | 24 | /** 25 | * @return array 26 | */ 27 | public function getData() 28 | { 29 | return $this->data; 30 | } 31 | 32 | /** 33 | * @param mixed $key 34 | * @return bool 35 | */ 36 | public function has($key) 37 | { 38 | return array_key_exists($key, $this->data); 39 | } 40 | 41 | /** 42 | * @param mixed $key; 43 | * @return mixed 44 | */ 45 | public function get($key) 46 | { 47 | if (!$this->has($key)) { 48 | throw new DataProviderException(sprintf('Data with key "%s" doesn\'t exists.', $key)); 49 | } 50 | return $this->data[$key]; 51 | } 52 | 53 | /** 54 | * @param mixed $key 55 | * @param mixed $data 56 | * @throws DataProviderException 57 | */ 58 | public function set($key, $data) 59 | { 60 | if (is_null($key)) { 61 | throw new DataProviderException('Key is null !'); 62 | } 63 | if (!is_scalar($key)) { 64 | throw new DataProviderException(sprintf('Key is not a scalar value, %s given.', gettype($key))); 65 | } 66 | $this->data[$key] = $data; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-babel/spec/player.spec.js: -------------------------------------------------------------------------------- 1 | describe('Player', () => { 2 | 'use strict'; 3 | 4 | let player; 5 | let song; 6 | 7 | beforeEach(() => { 8 | player = new Player(); 9 | song = new Song(); 10 | }); 11 | 12 | it('should be able to play a Song', () => { 13 | player.play(song); 14 | expect(player.currentlyPlayingSong).toEqual(song); 15 | 16 | //demonstrates use of custom matcher 17 | expect(player).toBePlaying(song); 18 | }); 19 | 20 | describe('when song has been paused', () => { 21 | beforeEach(() => { 22 | player.play(song); 23 | player.pause(); 24 | }); 25 | 26 | it('should indicate that the song is currently paused', () => { 27 | expect(player.isPlaying).toBeFalsy(); 28 | 29 | // demonstrates use of 'not' with a custom matcher 30 | expect(player).not.toBePlaying(song); 31 | }); 32 | 33 | it('should be possible to resume', () => { 34 | player.resume(); 35 | expect(player.isPlaying).toBeTruthy(); 36 | expect(player.currentlyPlayingSong).toEqual(song); 37 | }); 38 | }); 39 | 40 | // demonstrates use of spies to intercept and test method calls 41 | it('tells the current song if the user has made it a favorite', () => { 42 | spyOn(song, 'persistFavoriteStatus'); 43 | 44 | player.play(song); 45 | player.makeFavorite(); 46 | 47 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 48 | }); 49 | 50 | //demonstrates use of expected exceptions 51 | describe('#resume', () => { 52 | it('should throw an exception if song is already playing', () => { 53 | player.play(song); 54 | 55 | expect(() => player.resume()).toThrowError('song is already playing'); 56 | }); 57 | }); 58 | }); 59 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma-babel/test/PlayerSpec.js: -------------------------------------------------------------------------------- 1 | describe('Player', () => { 2 | 'use strict'; 3 | 4 | let player; 5 | let song; 6 | 7 | before(() => { 8 | player = new Player(); 9 | song = new Song(); 10 | }); 11 | 12 | it('should be able to play a Song', () => { 13 | player.play(song); 14 | 15 | assert.equal(1, 1); 16 | expect(player.currentlyPlayingSong).equal(song); 17 | }); 18 | 19 | describe('when song has been paused', () => { 20 | 21 | before(() => { 22 | player.play(song); 23 | player.pause(); 24 | }); 25 | 26 | it('should indicate that the song is currently paused', () => { 27 | 28 | expect(player.isPlaying).to.be.false; 29 | }); 30 | 31 | it('should be possible to resume', () => { 32 | player.resume(); 33 | 34 | expect(player.isPlaying).to.be.true; 35 | expect(player.currentlyPlayingSong).to.equal(song); 36 | }); 37 | }); 38 | 39 | // demonstrates use of spies to intercept and test method calls 40 | xit('tells the current song if the user has made it a favorite', () => { 41 | // REMOVE spyOn(song, 'persistFavoriteStatus'); 42 | 43 | // FIXME Comment gérer les Spy ? 44 | 45 | console.log(sinon.spy); 46 | sinon.spy(song, 'persistFavoriteStatus'); 47 | 48 | player.play(song); 49 | player.makeFavorite(); 50 | 51 | spy.calledWith(true); 52 | // expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 53 | }); 54 | 55 | //demonstrates use of expected exceptions 56 | xdescribe('#resume', () => { 57 | it('should throw an exception if song is already playing', () => { 58 | player.play(song); 59 | 60 | expect(() => { 61 | player.resume(); 62 | }).toThrowError('song is already playing'); 63 | }); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/spec/PlayerSpec.js: -------------------------------------------------------------------------------- 1 | describe("Player", function() { 2 | var player; 3 | var song; 4 | 5 | beforeEach(function() { 6 | player = new Player(); 7 | song = new Song(); 8 | }); 9 | 10 | it("should be able to play a Song", function() { 11 | player.play(song); 12 | expect(player.currentlyPlayingSong).toEqual(song); 13 | 14 | //demonstrates use of custom matcher 15 | expect(player).toBePlaying(song); 16 | }); 17 | 18 | describe("when song has been paused", function() { 19 | beforeEach(function() { 20 | player.play(song); 21 | player.pause(); 22 | }); 23 | 24 | it("should indicate that the song is currently paused", function() { 25 | expect(player.isPlaying).toBeFalsy(); 26 | 27 | // demonstrates use of 'not' with a custom matcher 28 | expect(player).not.toBePlaying(song); 29 | }); 30 | 31 | it("should be possible to resume", function() { 32 | player.resume(); 33 | expect(player.isPlaying).toBeTruthy(); 34 | expect(player.currentlyPlayingSong).toEqual(song); 35 | }); 36 | }); 37 | 38 | // demonstrates use of spies to intercept and test method calls 39 | it("tells the current song if the user has made it a favorite", function() { 40 | spyOn(song, 'persistFavoriteStatus'); 41 | 42 | player.play(song); 43 | player.makeFavorite(); 44 | 45 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 46 | }); 47 | 48 | //demonstrates use of expected exceptions 49 | describe("#resume", function() { 50 | it("should throw an exception if song is already playing", function() { 51 | player.play(song); 52 | 53 | expect(function() { 54 | player.resume(); 55 | }).toThrowError("song is already playing"); 56 | }); 57 | }); 58 | }); 59 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-htmlrunner/how-to-build.md: -------------------------------------------------------------------------------- 1 | # QUnit & HTML Runner 2 | 3 | Tout est décrit ici : https://qunitjs.com 4 | 5 | 6 | ## Create with CDN: 7 | 8 | Replace `x.x.x` by QUnit version. (ex: `qunit-1.18.0.js`) 9 | 10 | Create `TestRunner.html`: 11 | 12 | ```html 13 | 14 | 15 | 16 | 17 | QUnit Example 18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 | 27 | ``` 28 | 29 | 30 | ## Create without CDN: 31 | 32 | Replace `x.x.x` by QUnit version. (ex: `qunit-1.18.0.js`) 33 | 34 | Download: 35 | 36 | - http://code.jquery.com/qunit/qunit-x.x.x.js 37 | - http://code.jquery.com/qunit/qunit-x.x.x.css 38 | 39 | Create `TestRunner.html`: 40 | 41 | ```html 42 | 43 | 44 | 45 | 46 | QUnit Example 47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | 56 | 57 | ``` 58 | 59 | 60 | ## Run tests 61 | 62 | Open `TestRunner.html` file in your browser. 63 | 64 | 65 | ## Project structure 66 | 67 | ``` 68 | ├── lib 69 | │ ├── qunit-x.x.x.css 70 | │ └── qunit-x.x.x.js 71 | ├── src 72 | │ ├── file01.js 73 | │ ├── file02.js 74 | │ └── ... 75 | ├── test 76 | │ ├── file01.test.js 77 | │ ├── file02.test.js 78 | │ └── ... 79 | ├── TestRunner.html 80 | ├── .editorconfig 81 | └── .jshintrc 82 | ``` 83 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/spec/jasmine_examples/PlayerSpec.js: -------------------------------------------------------------------------------- 1 | describe('Player', function () { 2 | 'use strict'; 3 | 4 | var player; 5 | var song; 6 | 7 | beforeEach(function () { 8 | player = new Player(); 9 | song = new Song(); 10 | }); 11 | 12 | it('should be able to play a Song', function () { 13 | player.play(song); 14 | expect(player.currentlyPlayingSong).toEqual(song); 15 | 16 | //demonstrates use of custom matcher 17 | expect(player).toBePlaying(song); 18 | }); 19 | 20 | describe('when song has been paused', function () { 21 | beforeEach(function () { 22 | player.play(song); 23 | player.pause(); 24 | }); 25 | 26 | it('should indicate that the song is currently paused', function () { 27 | expect(player.isPlaying).toBeFalsy(); 28 | 29 | // demonstrates use of 'not' with a custom matcher 30 | expect(player).not.toBePlaying(song); 31 | }); 32 | 33 | it('should be possible to resume', function () { 34 | player.resume(); 35 | expect(player.isPlaying).toBeTruthy(); 36 | expect(player.currentlyPlayingSong).toEqual(song); 37 | }); 38 | }); 39 | 40 | // demonstrates use of spies to intercept and test method calls 41 | it('tells the current song if the user has made it a favorite', function () { 42 | spyOn(song, 'persistFavoriteStatus'); 43 | 44 | player.play(song); 45 | player.makeFavorite(); 46 | 47 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 48 | }); 49 | 50 | //demonstrates use of expected exceptions 51 | describe('#resume', function () { 52 | it('should throw an exception if song is already playing', function () { 53 | player.play(song); 54 | 55 | expect(function () { 56 | player.resume(); 57 | }).toThrowError('song is already playing'); 58 | }); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /groovy/config/codenarc/rules.groovy: -------------------------------------------------------------------------------- 1 | ruleset { 2 | description 'Rules Sample Groovy Gradle Project' 3 | 4 | ruleset('rulesets/basic.xml') 5 | 6 | ruleset('rulesets/braces.xml') 7 | 8 | ruleset('rulesets/exceptions.xml') 9 | 10 | ruleset('rulesets/imports.xml') { 11 | // we order static imports after other imports because that's the default style in IDEA 12 | MisorderedStaticImports { 13 | comesBefore = false 14 | } 15 | } 16 | 17 | ruleset('rulesets/logging.xml') { 18 | 'Println' priority: 1 19 | 'PrintStackTrace' priority: 1 20 | } 21 | 22 | ruleset('rulesets/naming.xml') 23 | 24 | ruleset('rulesets/convention.xml') 25 | 26 | ruleset('rulesets/design.xml') { 27 | // we don't care 28 | exclude 'AbstractClassWithoutAbstractMethod' 29 | } 30 | 31 | // the DRY rules do not necessarily lead to better code 32 | // ruleset('rulesets/dry.xml') 33 | 34 | ruleset('rulesets/enhanced.xml') 35 | 36 | ruleset('rulesets/formatting.xml') { 37 | exclude 'SpaceAroundMapEntryColon' 38 | exclude 'LineLength' 39 | } 40 | 41 | ruleset('rulesets/generic.xml') 42 | 43 | ruleset('rulesets/groovyism.xml') { 44 | // not necessarily an issue, problems should be detected by unit tests 45 | exclude 'GStringExpressionWithinString' 46 | } 47 | 48 | ruleset('rulesets/security.xml') { 49 | // we don't care because our classes need not to satisfy the Java Beans specification 50 | exclude 'JavaIoPackageAccess' 51 | // we don't care for now 52 | exclude 'FileCreateTempFile' 53 | } 54 | 55 | ruleset('rulesets/serialization.xml') 56 | 57 | // we don't care for now 58 | // ruleset('rulesets/size.xml') 59 | 60 | ruleset('rulesets/unnecessary.xml') 61 | 62 | ruleset('rulesets/unused.xml') 63 | } 64 | -------------------------------------------------------------------------------- /js/with-mocha/mocha/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Mocha project 2 | 3 | - http://mochajs.org 4 | 5 | ## Initiate NPM project 6 | 7 | ```shell 8 | npm init 9 | ``` 10 | 11 | Console output: 12 | 13 | ```shell 14 | This utility will walk you through creating a package.json file. 15 | It only covers the most common items, and tries to guess sensible defaults. 16 | 17 | See `npm help json` for definitive documentation on these fields 18 | and exactly what they do. 19 | 20 | Use `npm install --save` afterwards to install a package and 21 | save it as a dependency in the package.json file. 22 | 23 | Press ^C at any time to quit. 24 | name: (temp) my-mocha-project 25 | version: (1.0.0) 26 | description: My mocha project 27 | entry point: (index.js) 28 | test command: mocha test 29 | git repository: 30 | keywords: project, mocha 31 | author: you 32 | license: (ISC) 33 | About to write to ...\package.json: 34 | 35 | { 36 | "name": "my-mocha-project", 37 | "version": "1.0.0", 38 | "description": "My mocha project", 39 | "main": "index.js", 40 | "scripts": { 41 | "test": "mocha test" 42 | }, 43 | "keywords": [ 44 | "project", 45 | "mocha" 46 | ], 47 | "author": "you", 48 | "license": "ISC" 49 | } 50 | 51 | Is this ok? (yes) 52 | ``` 53 | 54 | ## Install Mocha 55 | 56 | ```shell 57 | npm install -D mocha chai sinon 58 | # Install Mocha globaly for use as command line tool 59 | npm install -g mocha 60 | ``` 61 | 62 | ## (optional) Initiate Mocha for Browser 63 | 64 | ```shell 65 | mocha init ./spec 66 | ``` 67 | 68 | ## Run tests 69 | 70 | ```shell 71 | # stand-alone 72 | mocha test 73 | # within NPM 74 | npm test 75 | ``` 76 | 77 | ## Project structure 78 | 79 | ``` 80 | ├── src 81 | │ ├── file01.js 82 | │ ├── file02.js 83 | │ └── ... 84 | ├── test 85 | │ ├── file01.test.js 86 | │ ├── file02.test.js 87 | │ └── ... 88 | ├── package.json 89 | ├── mocha.opts 90 | ├── .editorconfig 91 | └── .jshintrc 92 | ``` 93 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/spec/jasmine_examples/PlayerSpec.js: -------------------------------------------------------------------------------- 1 | describe('Player', function () { 2 | 'use strict'; 3 | 4 | var Player = require('../../lib/jasmine_examples/Player'); 5 | var Song = require('../../lib/jasmine_examples/Song'); 6 | var player; 7 | var song; 8 | 9 | beforeEach(function () { 10 | player = new Player(); 11 | song = new Song(); 12 | }); 13 | 14 | it('should be able to play a Song', function () { 15 | player.play(song); 16 | expect(player.currentlyPlayingSong).toEqual(song); 17 | 18 | //demonstrates use of custom matcher 19 | expect(player).toBePlaying(song); 20 | }); 21 | 22 | describe('when song has been paused', function () { 23 | beforeEach(function () { 24 | player.play(song); 25 | player.pause(); 26 | }); 27 | 28 | it('should indicate that the song is currently paused', function () { 29 | expect(player.isPlaying).toBeFalsy(); 30 | 31 | // demonstrates use of 'not' with a custom matcher 32 | expect(player).not.toBePlaying(song); 33 | }); 34 | 35 | it('should be possible to resume', function () { 36 | player.resume(); 37 | expect(player.isPlaying).toBeTruthy(); 38 | expect(player.currentlyPlayingSong).toEqual(song); 39 | }); 40 | }); 41 | 42 | // demonstrates use of spies to intercept and test method calls 43 | it('tells the current song if the user has made it a favorite', function () { 44 | spyOn(song, 'persistFavoriteStatus'); 45 | 46 | player.play(song); 47 | player.makeFavorite(); 48 | 49 | expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 50 | }); 51 | 52 | //demonstrates use of expected exceptions 53 | describe('#resume', function () { 54 | it('should throw an exception if song is already playing', function () { 55 | player.play(song); 56 | 57 | expect(function () { 58 | player.resume(); 59 | }).toThrowError('song is already playing'); 60 | }); 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/test/PlayerSpec.js: -------------------------------------------------------------------------------- 1 | import assert from 'assert'; 2 | import sinon from 'sinon'; 3 | import chai from 'chai'; 4 | const expect = chai.expect; 5 | 6 | import Player from '../src/Player'; 7 | import Song from '../src/Song'; 8 | 9 | describe('Player', () => { 10 | 'use strict'; 11 | 12 | let player; 13 | let song; 14 | 15 | before(() => { 16 | player = new Player(); 17 | song = new Song(); 18 | }); 19 | 20 | it('should be able to play a Song', () => { 21 | player.play(song); 22 | 23 | assert.equal(1, 1); 24 | expect(player.currentlyPlayingSong).equal(song); 25 | }); 26 | 27 | describe('when song has been paused', () => { 28 | 29 | before(() => { 30 | player.play(song); 31 | player.pause(); 32 | }); 33 | 34 | it('should indicate that the song is currently paused', () => { 35 | 36 | expect(player.isPlaying).to.be.false; 37 | }); 38 | 39 | it('should be possible to resume', () => { 40 | player.resume(); 41 | 42 | expect(player.isPlaying).to.be.true; 43 | expect(player.currentlyPlayingSong).to.equal(song); 44 | }); 45 | }); 46 | 47 | // demonstrates use of spies to intercept and test method calls 48 | xit('tells the current song if the user has made it a favorite', () => { 49 | // REMOVE spyOn(song, 'persistFavoriteStatus'); 50 | 51 | // FIXME Comment gérer les Spy ? 52 | 53 | console.log(sinon.spy); 54 | sinon.spy(song, 'persistFavoriteStatus'); 55 | 56 | player.play(song); 57 | player.makeFavorite(); 58 | 59 | spy.calledWith(true); 60 | // expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true); 61 | }); 62 | 63 | //demonstrates use of expected exceptions 64 | xdescribe('#resume', () => { 65 | it('should throw an exception if song is already playing', () => { 66 | player.play(song); 67 | 68 | expect(() => { 69 | player.resume(); 70 | }).toThrowError('song is already playing'); 71 | }); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /php/with-atoum/tests/Infrastructure/User/UserRepository.php: -------------------------------------------------------------------------------- 1 | testedClass 15 | ->implements(UserRepositoryInterface::class); 16 | } 17 | 18 | public function testGetById() 19 | { 20 | $this 21 | ->given( 22 | $providerMock = $this->createMockDataProvider(), 23 | $userIdMock = $this->createMockUserId(), 24 | $this->newTestedInstance($providerMock) 25 | ) 26 | ->object($this->testedInstance->getById($userIdMock)) 27 | ->isInstanceOf(User::class) 28 | 29 | // we check if mock's method was called one time 30 | ->mock($userIdMock) 31 | ->call('getId') 32 | ->once() 33 | 34 | ->mock($providerMock) 35 | ->call('has') 36 | ->once() 37 | 38 | ->mock($providerMock) 39 | ->call('get') 40 | ->once(); 41 | } 42 | 43 | private function createMockDataProvider() 44 | { 45 | $mock = new \mock\KataStarter\WithAtoum\Infrastructure\Provider\DataProviderInterface(); 46 | $mock->getMockController()->has = function($key) { 47 | return $key == 1234; 48 | }; 49 | $mock->getMockController()->get = $this->createMockUser(); 50 | return $mock; 51 | } 52 | 53 | private function createMockUser() 54 | { 55 | return new \mock\KataStarter\WithAtoum\Domain\User\User($this->createMockUserId()); 56 | } 57 | 58 | private function createMockUserId() 59 | { 60 | return new \mock\KataStarter\WithAtoum\Domain\User\UserId(1234); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /js/with-jest/jest-babel/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Jest & Babel project 2 | 3 | - https://facebook.github.io/jest/ 4 | 5 | 6 | ## Initiate NPM project 7 | 8 | ```shell 9 | npm init 10 | ``` 11 | 12 | Console output: 13 | 14 | ```shell 15 | This utility will walk you through creating a package.json file. 16 | It only covers the most common items, and tries to guess sensible defaults. 17 | 18 | See `npm help json` for definitive documentation on these fields 19 | and exactly what they do. 20 | 21 | Use `npm install --save` afterwards to install a package and 22 | save it as a dependency in the package.json file. 23 | 24 | Press ^C at any time to quit. 25 | name: (temp) my-jest-project 26 | version: (1.0.0) 27 | description: My jest project 28 | entry point: (index.js) 29 | test command: jest 30 | git repository: 31 | keywords: project, jest 32 | author: you 33 | license: (ISC) 34 | About to write to ...\package.json: 35 | 36 | { 37 | "name": "my-jest-project", 38 | "version": "1.0.0", 39 | "description": "My jest project", 40 | "main": "index.js", 41 | "scripts": { 42 | "test": "jest" 43 | }, 44 | "keywords": [ 45 | "project", 46 | "jest", 47 | "babel" 48 | ], 49 | "author": "you", 50 | "license": "ISC" 51 | } 52 | 53 | Is this ok? (yes) 54 | ``` 55 | 56 | 57 | ## Install Jest 58 | 59 | ```shell 60 | npm install -D jest 61 | ``` 62 | 63 | ## Install Babel 64 | 65 | ```shell 66 | npm install -D babel-jest babel-polyfill babel-preset-es2015 67 | ``` 68 | 69 | Add a `.babelrc` file in your project's root folder: 70 | 71 | ```json 72 | { 73 | "presets": ["es2015"] 74 | } 75 | ``` 76 | 77 | ## Run tests 78 | 79 | ```shell 80 | npm test 81 | ``` 82 | 83 | 84 | ## Project structure 85 | 86 | ``` 87 | ├── __tests__ 88 | │ ├── file01.js 89 | │ ├── file02.js 90 | │ └── ... 91 | ├── spec 92 | │ ├── file01.spec.js 93 | │ ├── file02.spec.js 94 | │ ├── file03.test.js 95 | │ └── ... 96 | ├── package.json 97 | ├── .babelrc 98 | ├── .editorconfig 99 | └── .jshintrc 100 | ``` 101 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Jasmine project 2 | 3 | - http://jasmine.github.io/edge/node.html 4 | 5 | 6 | ## Initiate NPM project 7 | 8 | ```shell 9 | npm init 10 | ``` 11 | 12 | Console output: 13 | 14 | ```shell 15 | This utility will walk you through creating a package.json file. 16 | It only covers the most common items, and tries to guess sensible defaults. 17 | 18 | See `npm help json` for definitive documentation on these fields 19 | and exactly what they do. 20 | 21 | Use `npm install --save` afterwards to install a package and 22 | save it as a dependency in the package.json file. 23 | 24 | Press ^C at any time to quit. 25 | name: (temp) my-jasmine-project 26 | version: (1.0.0) 27 | description: My jasmine project 28 | entry point: (index.js) 29 | test command: jasmine 30 | git repository: 31 | keywords: project, jasmine 32 | author: you 33 | license: (ISC) 34 | About to write to ...\package.json: 35 | 36 | { 37 | "name": "my-jasmine-project", 38 | "version": "1.0.0", 39 | "description": "My jasmine project", 40 | "main": "index.js", 41 | "scripts": { 42 | "test": "jasmine" 43 | }, 44 | "keywords": [ 45 | "project", 46 | "jasmine" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Jasmine 57 | 58 | ```shell 59 | npm install -D jasmine 60 | # Install Jasmine globaly for use as command line tool 61 | npm install -g jasmine 62 | ``` 63 | 64 | 65 | ## Initiate Jasmine 66 | 67 | ```shell 68 | jasmine init 69 | ``` 70 | 71 | 72 | ## (Optional) Generate examples 73 | 74 | ```shell 75 | jasmine examples 76 | ``` 77 | 78 | 79 | ## Run tests 80 | 81 | ```shell 82 | # stand-alone 83 | jasmine 84 | # within NPM 85 | npm test 86 | ``` 87 | 88 | 89 | ## Project structure 90 | 91 | ``` 92 | ├── lib 93 | │ ├── file01.js 94 | │ ├── file02.js 95 | │ └── ... 96 | ├── spec 97 | │ ├── file01.spec.js 98 | │ ├── file02.spec.js 99 | │ ├── ... 100 | │ ├── helpers 101 | │ │ └── ... 102 | │ └── support 103 | │ └── jasmine.json 104 | ├── package.json 105 | ├── .editorconfig 106 | └── .jshintrc 107 | ``` 108 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/karma.conf.coffee: -------------------------------------------------------------------------------- 1 | # Karma configuration 2 | # Generated on Mon Aug 03 2015 22:45:04 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = (config) -> 5 | config.set 6 | 7 | # base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '' 9 | 10 | # frameworks to use 11 | # available frameworks: https://npmjs.org/browse/keyword/karma-adapter 12 | frameworks: ['jasmine'] 13 | 14 | # list of files / patterns to load in the browser 15 | files: [ 16 | 'src/**/*.coffee' 17 | 'spec/**/*.coffee' 18 | ] 19 | 20 | # list of files to exclude 21 | exclude: [] 22 | 23 | # preprocess matching files before serving them to the browser 24 | # available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 25 | preprocessors: 26 | '+(src|spec)/**/*.coffee': 'coffee' 27 | 'src/**/!(*.spec).coffee': 'coverage' 28 | 29 | # test results reporter to use 30 | # possible values: 'dots', 'progress' 31 | # available reporters: https://npmjs.org/browse/keyword/karma-reporter 32 | reporters: ['dots', 'coverage'] 33 | 34 | # web server port 35 | port: 9876 36 | 37 | # enable / disable colors in the output (reporters and logs) 38 | colors: true 39 | 40 | # level of logging 41 | # possible values: 42 | # - config.LOG_DISABLE 43 | # - config.LOG_ERROR 44 | # - config.LOG_WARN 45 | # - config.LOG_INFO 46 | # - config.LOG_DEBUG 47 | logLevel: config.LOG_INFO 48 | 49 | # enable / disable watching file and executing tests whenever any file changes 50 | autoWatch: true 51 | 52 | # start these browsers 53 | # available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 54 | browsers: ['PhantomJS'] 55 | 56 | 57 | # Continuous Integration mode 58 | # if true, Karma captures browsers, runs the tests and exits 59 | singleRun: false 60 | 61 | # Coverage Reporter configuration 62 | coverageReporter: { 63 | reporters: [ 64 | # File output 65 | type: 'html' 66 | dir: 'coverage/' 67 | # supprime les dossiers spécifiques à chaque browser 68 | subdir: '.' 69 | , 70 | # Console output 71 | type: 'text' 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 18:24:05 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['jasmine'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.js', 19 | 'spec/**/*.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'src/**/!(*.spec).js': 'coverage' 29 | }, 30 | 31 | // test results reporter to use 32 | // possible values: 'dots', 'progress' 33 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 34 | reporters: ['dots', 'coverage'], 35 | 36 | // web server port 37 | port: 9876, 38 | 39 | // enable / disable colors in the output (reporters and logs) 40 | colors: true, 41 | 42 | // level of logging 43 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 44 | logLevel: config.LOG_INFO, 45 | 46 | // enable / disable watching file and executing tests whenever any file changes 47 | autoWatch: true, 48 | 49 | // start these browsers 50 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 51 | browsers: ['PhantomJS'], 52 | 53 | // Continuous Integration mode 54 | // if true, Karma captures browsers, runs the tests and exits 55 | singleRun: false, 56 | 57 | // Coverage Reporter configuration 58 | coverageReporter: { 59 | reporters: [ 60 | // File output 61 | { 62 | type: 'html', 63 | dir: 'coverage/', 64 | // supprime les dossiers spécifiques à chaque browser 65 | subdir: '.' 66 | }, 67 | // Console output 68 | { 69 | type: 'text' 70 | } 71 | ] 72 | } 73 | }); 74 | }; 75 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-karma/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 23:17:09 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['qunit'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.js', 19 | 'test/**/*.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'src/**/!(*.test).js': 'coverage' 29 | }, 30 | 31 | // test results reporter to use 32 | // possible values: 'dots', 'progress' 33 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 34 | reporters: ['dots', 'coverage'], 35 | 36 | // web server port 37 | port: 9876, 38 | 39 | // enable / disable colors in the output (reporters and logs) 40 | colors: true, 41 | 42 | // level of logging 43 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 44 | logLevel: config.LOG_INFO, 45 | 46 | // enable / disable watching file and executing tests whenever any file changes 47 | autoWatch: true, 48 | 49 | // start these browsers 50 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 51 | browsers: ['PhantomJS'], 52 | 53 | // Continuous Integration mode 54 | // if true, Karma captures browsers, runs the tests and exits 55 | singleRun: false, 56 | 57 | // Coverage Reporter configuration 58 | coverageReporter: { 59 | reporters: [ 60 | // File output 61 | { 62 | type: 'html', 63 | dir: 'coverage/', 64 | // supprime les dossiers spécifiques à chaque browser 65 | subdir: '.' 66 | }, 67 | // Console output 68 | { 69 | type: 'text' 70 | } 71 | ] 72 | } 73 | 74 | }); 75 | }; 76 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 18:55:51 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['mocha', 'chai', 'sinon'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.js', 19 | 'test/**/*.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'src/**/!(*.test).js': 'coverage' 29 | }, 30 | 31 | // test results reporter to use 32 | // possible values: 'dots', 'progress' 33 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 34 | reporters: ['dots', 'coverage'], 35 | 36 | // web server port 37 | port: 9876, 38 | 39 | // enable / disable colors in the output (reporters and logs) 40 | colors: true, 41 | 42 | // level of logging 43 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 44 | logLevel: config.LOG_INFO, 45 | 46 | // enable / disable watching file and executing tests whenever any file changes 47 | autoWatch: true, 48 | 49 | // start these browsers 50 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 51 | browsers: ['PhantomJS'], 52 | 53 | // Continuous Integration mode 54 | // if true, Karma captures browsers, runs the tests and exits 55 | singleRun: false, 56 | 57 | // Coverage Reporter configuration 58 | coverageReporter: { 59 | reporters: [ 60 | // File output 61 | { 62 | type: 'html', 63 | dir: 'coverage/', 64 | // supprime les dossiers spécifiques à chaque browser 65 | subdir: '.' 66 | }, 67 | // Console output 68 | { 69 | type: 'text' 70 | } 71 | ] 72 | } 73 | 74 | }); 75 | }; 76 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-babel/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Mocha project 2 | 3 | - http://mochajs.org 4 | 5 | ## Initiate NPM project 6 | 7 | ```shell 8 | npm init 9 | ``` 10 | 11 | Console output: 12 | 13 | ```shell 14 | This utility will walk you through creating a package.json file. 15 | It only covers the most common items, and tries to guess sensible defaults. 16 | 17 | See `npm help json` for definitive documentation on these fields 18 | and exactly what they do. 19 | 20 | Use `npm install --save` afterwards to install a package and 21 | save it as a dependency in the package.json file. 22 | 23 | Press ^C at any time to quit. 24 | name: (temp) my-mocha-project 25 | version: (1.0.0) 26 | description: My mocha project 27 | entry point: (index.js) 28 | test command: mocha test 29 | git repository: 30 | keywords: project, mocha, babel 31 | author: you 32 | license: (ISC) 33 | About to write to ...\package.json: 34 | 35 | { 36 | "name": "my-mocha-project", 37 | "version": "1.0.0", 38 | "description": "My mocha project", 39 | "main": "index.js", 40 | "scripts": { 41 | "test": "mocha test" 42 | }, 43 | "keywords": [ 44 | "project", 45 | "mocha", 46 | "babel" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | ## Install Mocha 56 | 57 | ```shell 58 | npm install -D mocha chai sinon 59 | # Install Mocha globaly for use as command line tool 60 | npm install -g mocha 61 | ``` 62 | 63 | ## (optional) Initiate Mocha for Browser 64 | 65 | ```shell 66 | mocha init ./spec 67 | ``` 68 | 69 | ## Run tests 70 | 71 | ```shell 72 | # stand-alone 73 | mocha test 74 | # within NPM 75 | npm test 76 | ``` 77 | 78 | ## Babel 79 | 80 | - Install 81 | 82 | ```shell 83 | npm install -D babel 84 | ``` 85 | 86 | - Configure 87 | 88 | ```json 89 | [...] 90 | "scripts": { 91 | "test": "mocha --compilers js:babel/register" 92 | }, 93 | [...] 94 | ``` 95 | 96 | 97 | ## Run tests 98 | 99 | ```shell 100 | npm test 101 | ``` 102 | 103 | 104 | ## Project structure 105 | 106 | ``` 107 | ├── src 108 | │ ├── file01.js 109 | │ ├── file02.js 110 | │ └── ... 111 | ├── test 112 | │ ├── file01.test.js 113 | │ ├── file02.test.js 114 | │ └── ... 115 | ├── package.json 116 | ├── mocha.opts 117 | ├── .editorconfig 118 | └── .jshintrc 119 | ``` 120 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/karma.conf - Copie.coffee: -------------------------------------------------------------------------------- 1 | # Karma configuration 2 | # Generated on Mon Aug 03 2015 22:45:04 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = (config) -> 5 | config.set 6 | 7 | # base path that will be used to resolve all patterns (eg. files, exclude) 8 | basePath: '' 9 | 10 | # frameworks to use 11 | # available frameworks: https://npmjs.org/browse/keyword/karma-adapter 12 | frameworks: ['jasmine'] 13 | 14 | # list of files / patterns to load in the browser 15 | files: [ 16 | 'src/**/*.coffee' 17 | 'spec/**/*.coffee' 18 | ] 19 | 20 | # list of files to exclude 21 | exclude: [] 22 | 23 | # preprocess matching files before serving them to the browser 24 | # available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 25 | preprocessors: 26 | 'src/**/!(*.spec).coffee': 'coverage' 27 | 'spec/**/*.coffee': 'coffee' 28 | 29 | # test results reporter to use 30 | # possible values: 'dots', 'progress' 31 | # available reporters: https://npmjs.org/browse/keyword/karma-reporter 32 | reporters: ['dots', 'coverage'] 33 | 34 | # web server port 35 | port: 9876 36 | 37 | # enable / disable colors in the output (reporters and logs) 38 | colors: true 39 | 40 | # level of logging 41 | # possible values: 42 | # - config.LOG_DISABLE 43 | # - config.LOG_ERROR 44 | # - config.LOG_WARN 45 | # - config.LOG_INFO 46 | # - config.LOG_DEBUG 47 | logLevel: config.LOG_INFO 48 | 49 | # enable / disable watching file and executing tests whenever any file changes 50 | autoWatch: true 51 | 52 | # start these browsers 53 | # available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 54 | browsers: ['PhantomJS'] 55 | 56 | 57 | # Continuous Integration mode 58 | # if true, Karma captures browsers, runs the tests and exits 59 | singleRun: false 60 | 61 | # Coffee Preprocessor configuration 62 | coffeePreprocessor: 63 | options: 64 | sourceMap: true 65 | 66 | # Coverage Reporter configuration 67 | coverageReporter: 68 | instrumenters: 69 | ibrik : require('ibrik') 70 | instrumenter: 71 | '**/*.coffee': 'ibrik' 72 | type: 'text' 73 | # reporters: [ 74 | # # File output 75 | # type: 'html' 76 | # dir: 'coverage/' 77 | # # supprime les dossiers spécifiques à chaque browser 78 | # subdir: '.' 79 | # , 80 | # # Console output 81 | # type: 'text' 82 | # ] 83 | -------------------------------------------------------------------------------- /php/with-atoum/.atoum.php: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 16 | 17 | /* 18 | LOGO 19 | 20 | // This will add the atoum logo before each run. 21 | $report->addField(new atoum\report\fields\runner\atoum\logo()); 22 | 23 | // This will add a green or red logo after each run depending on its status. 24 | $report->addField(new atoum\report\fields\runner\result\logo()); 25 | */ 26 | 27 | /* 28 | CODE COVERAGE SETUP 29 | 30 | // Please replace in next line "Project Name" by your project name and "/path/to/destination/directory" by your destination directory path for html files. 31 | $coverageField = new atoum\report\fields\runner\coverage\html('Project Name', '/path/to/destination/directory'); 32 | 33 | // Please replace in next line http://url/of/web/site by the root url of your code coverage web site. 34 | $coverageField->setRootUrl('http://url/of/web/site'); 35 | 36 | $report->addField($coverageField); 37 | */ 38 | 39 | /* 40 | TEST EXECUTION SETUP 41 | 42 | // Please replace in next line "/path/to/your/tests/units/classes/directory" by your unit test's directory. 43 | $runner->addTestsFromDirectory('path/to/your/tests/units/classes/directory'); 44 | */ 45 | 46 | /* 47 | TEST GENERATOR SETUP 48 | 49 | $testGenerator = new atoum\test\generator(); 50 | 51 | // Please replace in next line "/path/to/your/tests/units/classes/directory" by your unit test's directory. 52 | $testGenerator->setTestClassesDirectory('path/to/your/tests/units/classes/directory'); 53 | 54 | // Please replace in next line "your\project\namespace\tests\units" by your unit test's namespace. 55 | $testGenerator->setTestClassNamespace('your\project\namespace\tests\units'); 56 | 57 | // Please replace in next line "/path/to/your/classes/directory" by your classes directory. 58 | $testGenerator->setTestedClassesDirectory('path/to/your/classes/directory'); 59 | 60 | // Please replace in next line "your\project\namespace" by your project namespace. 61 | $testGenerator->setTestedClassNamespace('your\project\namespace'); 62 | 63 | // Please replace in next line "path/to/your/tests/units/runner.php" by path to your unit test's runner. 64 | $testGenerator->setRunnerPath('path/to/your/tests/units/runner.php'); 65 | 66 | $script->getRunner()->setTestGenerator($testGenerator); 67 | */ 68 | -------------------------------------------------------------------------------- /groovy/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /java/java-graddle/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-babel/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 18:39:57 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['jasmine'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.js', 19 | 'spec/**/*.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'spec/**/*.js': ['babel'], 29 | 'src/**/!(*.spec).js': ['coverage', 'babel'] 30 | }, 31 | 32 | // test results reporter to use 33 | // possible values: 'dots', 'progress' 34 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 35 | reporters: ['dots', 'coverage'], 36 | 37 | // web server port 38 | port: 9876, 39 | 40 | // enable / disable colors in the output (reporters and logs) 41 | colors: true, 42 | 43 | // level of logging 44 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 45 | logLevel: config.LOG_INFO, 46 | 47 | // enable / disable watching file and executing tests whenever any file changes 48 | autoWatch: true, 49 | 50 | // start these browsers 51 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 52 | browsers: ['PhantomJS'], 53 | 54 | // Continuous Integration mode 55 | // if true, Karma captures browsers, runs the tests and exits 56 | singleRun: false, 57 | 58 | // Babel preprocessor configuration 59 | babelPreprocessor: { 60 | options: { 61 | // sourceMap: 'inline' 62 | }, 63 | filename: function (file) { 64 | return file.originalPath.replace(/\.js$/, '.es5.js'); 65 | }, 66 | sourceFileName: function (file) { 67 | return file.originalPath; 68 | } 69 | }, 70 | 71 | // Coverage Reporter configuration 72 | coverageReporter: { 73 | reporters: [ 74 | // File output 75 | { 76 | type: 'html', 77 | dir: 'coverage/', 78 | // supprime les dossiers spécifiques à chaque browser 79 | subdir: '.' 80 | }, 81 | // Console output 82 | { 83 | type: 'text' 84 | } 85 | ] 86 | } 87 | 88 | }); 89 | }; 90 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-typescript/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 21:39:41 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['jasmine'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.ts', 19 | 'spec/**/*.ts' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | '+(src|spec)/**/*.ts': ['typescript'], 29 | 'src/**/!(*.test).ts': 'coverage' 30 | }, 31 | 32 | // test results reporter to use 33 | // possible values: 'dots', 'progress' 34 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 35 | reporters: ['dots', 'coverage'], 36 | 37 | // web server port 38 | port: 9876, 39 | 40 | // enable / disable colors in the output (reporters and logs) 41 | colors: true, 42 | 43 | // level of logging 44 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 45 | logLevel: config.LOG_INFO, 46 | 47 | // enable / disable watching file and executing tests whenever any file changes 48 | autoWatch: true, 49 | 50 | // start these browsers 51 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 52 | browsers: ['PhantomJS'], 53 | 54 | // Continuous Integration mode 55 | // if true, Karma captures browsers, runs the tests and exits 56 | singleRun: false, 57 | 58 | // TypeScript preprocessor configuration 59 | typescriptPreprocessor: { 60 | // options passed to the typescript compiler 61 | options: { 62 | target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5' 63 | noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type. 64 | } 65 | }, 66 | 67 | // Coverage Reporter configuration 68 | coverageReporter: { 69 | reporters: [ 70 | // File output 71 | { 72 | type: 'html', 73 | dir: 'coverage/', 74 | // supprime les dossiers spécifiques à chaque browser 75 | subdir: '.' 76 | }, 77 | // Console output 78 | { 79 | type: 'text' 80 | } 81 | ] 82 | } 83 | 84 | }); 85 | }; 86 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma-babel/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Aug 02 2015 19:34:24 GMT+0200 (Paris, Madrid (heure d’été)) 3 | 4 | module.exports = function (config) { 5 | 'use strict'; 6 | 7 | config.set({ 8 | 9 | // base path that will be used to resolve all patterns (eg. files, exclude) 10 | basePath: '', 11 | 12 | // frameworks to use 13 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 14 | frameworks: ['mocha', 'chai', 'sinon'], 15 | 16 | // list of files / patterns to load in the browser 17 | files: [ 18 | 'src/**/*.js', 19 | 'test/**/*.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'test/**/*.js': ['babel'], 29 | 'src/**/!(*.test).js': ['coverage', 'babel'] 30 | }, 31 | 32 | // test results reporter to use 33 | // possible values: 'dots', 'progress' 34 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 35 | reporters: ['dots', 'coverage'], 36 | 37 | // web server port 38 | port: 9876, 39 | 40 | // enable / disable colors in the output (reporters and logs) 41 | colors: true, 42 | 43 | // level of logging 44 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 45 | logLevel: config.LOG_INFO, 46 | 47 | // enable / disable watching file and executing tests whenever any file changes 48 | autoWatch: true, 49 | 50 | // start these browsers 51 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 52 | browsers: ['PhantomJS'], 53 | 54 | // Continuous Integration mode 55 | // if true, Karma captures browsers, runs the tests and exits 56 | singleRun: false, 57 | 58 | // Babel preprocessor configuration 59 | babelPreprocessor: { 60 | options: { 61 | // sourceMap: 'inline' 62 | }, 63 | filename: function (file) { 64 | return file.originalPath.replace(/\.js$/, '.es5.js'); 65 | }, 66 | sourceFileName: function (file) { 67 | return file.originalPath; 68 | } 69 | }, 70 | 71 | // Coverage Reporter configuration 72 | coverageReporter: { 73 | reporters: [ 74 | // sortie fichier 75 | { 76 | type: 'html', 77 | dir: 'coverage/', 78 | // supprime les dossiers spécifiques à chaque browser 79 | subdir: '.' 80 | }, 81 | // sortie console 82 | { 83 | type: 'text' 84 | } 85 | ], 86 | instrumenters: { 87 | isparta: require('isparta') 88 | }, 89 | instrumenter: { 90 | '**/*.js': 'isparta' 91 | } 92 | } 93 | 94 | }); 95 | }; 96 | -------------------------------------------------------------------------------- /js/readme.md: -------------------------------------------------------------------------------- 1 | # Kata Template JS 2 | 3 | ## Jasmine 4 | 5 | ### Jasmine - HTML Runner 6 | 7 | - Uniquement Jasmine. 8 | - Pas de couverture de code. 9 | 10 | Run tests: Open `SpecRunner.html` file in your browser. 11 | 12 | 13 | ### Jasmine 14 | 15 | - Uniquement Jasmine. 16 | - Pas de couverture de code. 17 | 18 | Run tests: `jasmine` or `npm test`. 19 | 20 | 21 | ### Jasmine & Karma 22 | 23 | - Karma utilise Jasmine. 24 | - Couverture de code en sortie console ou fichier. 25 | 26 | Run tests: `karma start` or `npm test`. 27 | 28 | 29 | ### Jasmine & Karma & Babel 30 | 31 | - Karma utilise Jasmine. 32 | - Le code de l'application et des tests peuvent être écrit en ES2015+ (via Babel). 33 | - Couverture de code en sortie console ou fichier. 34 | 35 | Run tests: `karma start` or `npm test`. 36 | 37 | 38 | ### Jasmine & Karma & CoffeeScript 39 | 40 | - Karma utilise Jasmine. 41 | - Le code de l'application et des tests doivent être écrit en CoffeeScript. 42 | - Couverture de code en sortie console ou fichier. 43 | 44 | Run tests: `karma start` or `npm test`. 45 | 46 | 47 | ### Jasmine & Karma & TypeScript 48 | 49 | - Karma utilise Jasmine. 50 | - Le code de l'application et des tests doivent être écrit en TypeScript. 51 | - Couverture de code en sortie console ou fichier. 52 | 53 | Run tests: `karma start` or `npm test`. 54 | 55 | 56 | ## Mocha 57 | 58 | ### Mocha - HTML Runner 59 | 60 | - Uniquement Mocha. 61 | - Pas de couverture de code. 62 | 63 | TODO récupperer le dossier de l'ancien projet et ajouter le point d'entrée ici. 64 | 65 | 66 | ### Mocha 67 | 68 | - Uniquement Mocha. 69 | - Pas de couverture de code. 70 | 71 | Run tests: `mocha test` or `npm test`. 72 | 73 | 74 | ### Mocha & Babel 75 | 76 | - Uniquement Mocha. 77 | - Pas de couverture de code. 78 | 79 | Run tests: `npm test`. 80 | 81 | 82 | ### Mocha & Karma 83 | 84 | - Karma utilise Mocha. 85 | - Couverture de code en sortie console ou fichier. 86 | 87 | Run tests: `karma start` or `npm test`. 88 | 89 | 90 | ### Mocha & Karma & Babel 91 | 92 | - Karma utilise Mocha. 93 | - Le code de l'application et des tests peuvent être écrit en ES2015+ (via Babel). 94 | - Couverture de code en sortie console ou fichier. 95 | 96 | Run tests: `karma start` or `npm test`. 97 | 98 | 99 | ## QUnit 100 | 101 | ### QUnit - HTML Runner 102 | 103 | - Uniquement QUnit. 104 | - Pas de couverture de code. 105 | 106 | Run tests: Open `TestRunner.html` file in your browser. 107 | 108 | 109 | ### QUnit & Karma 110 | 111 | - Karma utilise QUnit. 112 | - Couverture de code en sortie console ou fichier. 113 | 114 | Run tests: `karma start` or `npm test`. 115 | 116 | 117 | ## Jest 118 | 119 | ### Jest 120 | 121 | - Uniquement Jest. 122 | 123 | Run tests: `npm test`. 124 | 125 | ### Jest & Babel 126 | 127 | - Uniquement Jest. 128 | - Le code de l'application et des tests peuvent être écrit en ES2015+ (via Babel). 129 | 130 | Run tests: `npm test`. 131 | -------------------------------------------------------------------------------- /js/references.md: -------------------------------------------------------------------------------- 1 | # Kata Template JS - References 2 | 3 | - [Node.js](https://nodejs.org) 4 | 5 | 6 | ## Karma 7 | 8 | - [Karma](http://karma-runner.github.io) 9 | 10 | ```shell 11 | npm install 12 | npm install -g karma-cli 13 | karma start 14 | ``` 15 | 16 | 17 | ## Jasmine 18 | 19 | - [Jasmine - API](http://jasmine.github.io) 20 | - [jasmine-standalone-x.x.x.zip](https://github.com/jasmine/jasmine/releases) 21 | - [karma-jasmine](https://github.com/karma-runner/karma-jasmine) 22 | 23 | 24 | ## QUnit 25 | 26 | - [QUnit](https://qunitjs.com) [Github](https://github.com/jquery/qunit) 27 | - [QUnit - API](http://api.qunitjs.com) 28 | - [karma-qunit](https://github.com/karma-runner/karma-qunit) 29 | 30 | 31 | ## Mocha 32 | 33 | - [Mocha](http://mochajs.org) [Github](https://github.com/mochajs/mocha) 34 | - [karma-mocha](https://github.com/karma-runner/karma-mocha) 35 | - [Sinon.JS](https://github.com/cjohansen/Sinon.JS) 36 | - [karma-sinon](https://github.com/yanoosh/karma-sinon) 37 | - [Chai.js](http://chaijs.com) 38 | - [karma-chai](https://github.com/xdissent/karma-chai) 39 | - [should.js](https://github.com/shouldjs/should.js) 40 | - [karma-should](https://github.com/seegno/karma-should) 41 | 42 | 43 | ## Jest 44 | 45 | - [Jest](https://facebook.github.io/jest) 46 | 47 | 48 | ## CoffeeScript 49 | 50 | - [CoffeeScript](http://coffeescript.org) [Github](https://github.com/jashkenas/coffeescript) 51 | - [karma-coffee-preprocessor](https://github.com/karma-runner/karma-coffee-preprocessor) 52 | - [ibrik](https://github.com/Constellation/ibrik): Istanbul instrumentation 53 | - [karma.conf.coffee](https://github.com/karma-runner/karma-coverage/blob/master/examples/coffee/karma.conf.coffee) 54 | - [coffee-coverage](https://github.com/benbria/coffee-coverage): ?? 55 | 56 | 57 | ## TypeScript 58 | 59 | - [TypeScript](http://www.typescriptlang.org/) [Github](https://github.com/Microsoft/TypeScript) 60 | - [karma-typescript-preprocessor](https://github.com/sergeyt/karma-typescript-preprocessor) 61 | - [DefinitelyTyped - Jasmine](https://github.com/borisyankov/DefinitelyTyped/tree/master/jasmine) 62 | 63 | 64 | ## Babel 65 | 66 | - [Babel](https://babeljs.io) 67 | - [es6-features](http://es6-features.org) 68 | - [karma-babel-preprocessor](https://github.com/babel/karma-babel-preprocessor) 69 | - [Isparta](https://github.com/douglasduteil/isparta): Istanbul instrumentation 70 | - [Webpack](http://webpack.github.io) 71 | - [Browserify](http://browserify.org) 72 | 73 | 74 | ## Coverage & Reporter 75 | 76 | - [Istanbul](https://gotwarlost.github.io/istanbul) [Github](https://github.com/gotwarlost/istanbul) 77 | - [Istanbul-hamony](https://github.com/fengmk2/istanbul) 78 | - [karma-coverage](https://github.com/karma-runner/karma-coverage) 79 | - [karma-coverage-es6](https://www.npmjs.com/package/karma-coverage-es6): pas de dépôt Github, semble expérimental 80 | - [karma-junit-reporter](https://github.com/karma-runner/karma-junit-reporter) 81 | - [karma-html-reporter](https://github.com/dtabuenc/karma-html-reporter) 82 | 83 | 84 | ## Others 85 | 86 | - [karma-html2js-preprocessor](https://github.com/karma-runner/karma-html2js-preprocessor) 87 | 88 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-karma/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & QUnit 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-qunit-project 24 | version: (1.0.0) 25 | description: My QUnit project 26 | entry point: (index.js) 27 | test command: karma start 28 | git repository: 29 | keywords: project, QUnit, karma 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-qunit-project", 36 | "version": "1.0.0", 37 | "description": "My QUnit project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "karma start" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "QUnit", 45 | "karma" 46 | ], 47 | "author": "you", 48 | "license": "ISC" 49 | } 50 | 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma 57 | 58 | ```shell 59 | npm install -D karma 60 | # npm install -D karma qunit karma-qunit karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init 79 | ``` 80 | 81 | Console output : 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > qunit 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.js 102 | WARN [init]: There is no file matching this pattern. 103 | > test/**/*.js 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.js". 117 | ``` 118 | 119 | 120 | ## Run tests 121 | 122 | ```shell 123 | # stand-alone 124 | karma start 125 | # within NPM 126 | npm test 127 | ``` 128 | 129 | 130 | ## Install Karma Coverage 131 | 132 | ```shell 133 | # Coverage 134 | npm install -D karma-coverage 135 | ``` 136 | 137 | 138 | ## karma.conf.js & coverage 139 | 140 | ```javascript 141 | [...] 142 | preprocessors: { 143 | 'src/**/!(*.test).js': 'coverage' 144 | }, 145 | [...] 146 | reporters: ['dots', 'coverage'], 147 | [...] 148 | // Coverage Reporter configuration 149 | coverageReporter: { 150 | reporters: [ 151 | // File output 152 | { 153 | type: 'html', 154 | dir: 'coverage/', 155 | // supprime les dossiers spécifiques à chaque browser 156 | subdir: '.' 157 | }, 158 | // Console output 159 | { 160 | type: 'text' 161 | } 162 | ] 163 | }, 164 | [...] 165 | ``` 166 | 167 | 168 | ## Project structure 169 | 170 | ``` 171 | ├── src 172 | │ ├── file01.js 173 | │ ├── file02.js 174 | │ └── ... 175 | ├── test 176 | │ ├── file01.test.js 177 | │ ├── file02.test.js 178 | │ └── ... 179 | ├── package.json 180 | ├── karma.conf.js 181 | ├── .editorconfig 182 | └── .jshintrc 183 | ``` 184 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Jasmine 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-jasmine-project 24 | version: (1.0.0) 25 | description: My jasmine project 26 | entry point: (index.js) 27 | test command: karma start 28 | git repository: 29 | keywords: project, jasmine, karma 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-jasmine-project", 36 | "version": "1.0.0", 37 | "description": "My jasmine project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "karma start" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "jasmine", 45 | "karma" 46 | ], 47 | "author": "you", 48 | "license": "ISC" 49 | } 50 | 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma 57 | 58 | ```shell 59 | npm install -D karma 60 | # npm install -D karma jasmine-core karma-jasmine karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init 79 | ``` 80 | 81 | Console output : 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > jasmine 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.js 102 | WARN [init]: There is no file matching this pattern. 103 | > spec/**/*.js 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.js". 117 | ``` 118 | 119 | 120 | ## Run tests 121 | 122 | ```shell 123 | # stand-alone 124 | karma start 125 | # within NPM 126 | npm test 127 | ``` 128 | 129 | 130 | ## Install Karma Coverage 131 | 132 | ```shell 133 | # Coverage 134 | npm install -D karma-coverage 135 | ``` 136 | 137 | 138 | ## karma.conf.js & coverage 139 | 140 | ```javascript 141 | [...] 142 | preprocessors: { 143 | 'src/**/!(*.spec).js': 'coverage' 144 | }, 145 | [...] 146 | reporters: ['dots', 'coverage'], 147 | [...] 148 | // Coverage Reporter configuration 149 | coverageReporter: { 150 | reporters: [ 151 | // File output 152 | { 153 | type: 'html', 154 | dir: 'coverage/', 155 | // supprime les dossiers spécifiques à chaque browser 156 | subdir: '.' 157 | }, 158 | // Console output 159 | { 160 | type: 'text' 161 | } 162 | ] 163 | }, 164 | [...] 165 | ``` 166 | 167 | 168 | ## Project structure 169 | 170 | ``` 171 | ├── src 172 | │ ├── file01.js 173 | │ ├── file02.js 174 | │ └── ... 175 | ├── spec 176 | │ ├── file01.spec.js 177 | │ ├── file02.spec.js 178 | │ └── ... 179 | ├── package.json 180 | ├── karma.conf.js 181 | ├── .editorconfig 182 | └── .jshintrc 183 | ``` 184 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Mocha 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-mocha-project 24 | version: (1.0.0) 25 | description: My mocha project 26 | entry point: (index.js) 27 | test command: mocha test 28 | git repository: 29 | keywords: project, mocha, karma 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-mocha-project", 36 | "version": "1.0.0", 37 | "description": "My mocha project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "mocha test" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "mocha", 45 | "karma 46 | ], 47 | "author": "you", 48 | "license": "ISC" 49 | } 50 | 51 | Is this ok? (yes) 52 | ``` 53 | 54 | 55 | ## Install Karma, Chai & Sinon 56 | 57 | ```shell 58 | npm install -D karma chai karma-chai sinon karma-sinon 59 | # npm install -D karma chai karma-chai sinon karma-sinon mocha karma-mocha karma-phantomjs-launcher phantomjs 60 | ``` 61 | 62 | 63 | ## Install Karma as command line tool 64 | 65 | ```shell 66 | # linux 67 | npm install -g karma 68 | # windows 69 | npm install -g karma-cli 70 | ``` 71 | 72 | 73 | ## Initiate Karma project 74 | 75 | ```shell 76 | # Initiate Karma 77 | karma init 78 | ``` 79 | 80 | Console output: 81 | 82 | ```shell 83 | Which testing framework do you want to use ? 84 | Press tab to list possible options. Enter to move to the next question. 85 | > mocha 86 | 87 | Do you want to use Require.js ? 88 | This will add Require.js plugin. 89 | Press tab to list possible options. Enter to move to the next question. 90 | > no 91 | 92 | Do you want to capture any browsers automatically ? 93 | Press tab to list possible options. Enter empty string to move to the next question. 94 | > PhantomJS 95 | > 96 | 97 | What is the location of your source and test files ? 98 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 99 | Enter empty string to move to the next question. 100 | > src/**/*.js 101 | WARN [init]: There is no file matching this pattern. 102 | > test/**/*.js 103 | WARN [init]: There is no file matching this pattern. 104 | > 105 | 106 | Should any of the files included by the previous patterns be excluded ? 107 | You can use glob patterns, eg. "**/*.swp". 108 | Enter empty string to move to the next question. 109 | > 110 | 111 | Do you want Karma to watch all the files and run the tests on change ? 112 | Press tab to list possible options. 113 | > yes 114 | 115 | Config file generated at "...\karma.conf.js". 116 | ``` 117 | 118 | 119 | ## karma.conf.js & Mocha, Chai, Sinon 120 | 121 | ```javascript 122 | [...] 123 | frameworks: ['mocha', 'chai', 'sinon'], 124 | [...] 125 | ``` 126 | 127 | 128 | ## Run tests 129 | 130 | ```shell 131 | # stand-alone 132 | karma start 133 | # within NPM 134 | npm test 135 | ``` 136 | 137 | 138 | ## Install Karma Coverage 139 | 140 | ```shell 141 | # Coverage 142 | npm install -D karma-coverage 143 | ``` 144 | 145 | 146 | ## karma.conf.js & coverage 147 | 148 | ```javascript 149 | [...] 150 | preprocessors: { 151 | 'src/**/!(*.test).js': 'coverage' 152 | }, 153 | [...] 154 | reporters: ['dots', 'coverage'], 155 | [...] 156 | // Coverage Reporter configuration 157 | coverageReporter: { 158 | reporters: [ 159 | // File output 160 | { 161 | type: 'html', 162 | dir: 'coverage/', 163 | // supprime les dossiers spécifiques à chaque browser 164 | subdir: '.' 165 | }, 166 | // Console output 167 | { 168 | type: 'text' 169 | } 170 | ] 171 | }, 172 | [...] 173 | ``` 174 | 175 | 176 | ## Project structure 177 | 178 | ``` 179 | ├── src 180 | │ ├── file01.js 181 | │ ├── file02.js 182 | │ └── ... 183 | ├── test 184 | │ ├── file01.test.js 185 | │ ├── file02.test.js 186 | │ └── ... 187 | ├── package.json 188 | ├── karma.conf.js 189 | ├── .editorconfig 190 | └── .jshintrc 191 | ``` 192 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-coffeescript/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Jasmine & CoffeeScript 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-coffeescript-project 24 | version: (1.0.0) 25 | description: My CoffeeScript project 26 | entry point: (index.js) 27 | test command: karma start 28 | git repository: 29 | keywords: project, jasmine, karma, CoffeeScript 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-coffeescript-project", 36 | "version": "1.0.0", 37 | "description": "My CoffeeScript project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "karma start" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "jasmine", 45 | "karma", 46 | "CoffeeScript" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma & CoffeeScript 57 | 58 | ```shell 59 | npm install -D karma karma-coffee-preprocessor 60 | # npm install -D karma coffee-script karma-coffee-preprocessor jasmine-core karma-jasmine karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init karma.conf.coffee 79 | ``` 80 | 81 | Console output : 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > jasmine 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.coffee 102 | WARN [init]: There is no file matching this pattern. 103 | > spec/**/*.coffee 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.coffee". 117 | ``` 118 | 119 | 120 | ## karma.conf.coffee & CoffeeScript 121 | 122 | ```coffeescript 123 | [...] 124 | preprocessors: 125 | '+(src|spec)/**/*.coffee': 'coffee' 126 | [...] 127 | ``` 128 | 129 | 130 | ## Run tests 131 | 132 | ```shell 133 | # stand-alone 134 | karma start 135 | # within NPM 136 | npm test 137 | ``` 138 | 139 | 140 | ## Install Karma Coverage 141 | 142 | ```shell 143 | # Coverage 144 | npm install -D karma-coverage 145 | ``` 146 | 147 | 148 | ## karma.conf.coffee & coverage 149 | 150 | Attention le preprocessor doit se situer **après** celui de CoffeeScript car Istanbul ne sait pas instrumenter CoffeeScript. 151 | 152 | La couverture de code sera alors donner sur le code généré en JS au lieu du CoffeeScript. 153 | 154 | Il exite une extension [Ibrik](https://github.com/Constellation/ibrik) pour instrumenter le CoffeeScript mais pour l'instant je n'arrive pas à le faire fonctionner. 155 | 156 | ```coffeescript 157 | [...] 158 | preprocessors: 159 | '+(src|spec)/**/*.coffee': 'coffee' 160 | 'src/**/!(*.spec).coffee': 'coverage' 161 | [...] 162 | reporters: ['dots', 'coverage'] 163 | [...] 164 | coverageReporter: 165 | reporters: [ 166 | # File output 167 | type: 'html' 168 | dir: 'coverage/' 169 | # supprime les dossiers spécifiques à chaque browser 170 | subdir: '.' 171 | , 172 | # Console output 173 | type: 'text' 174 | ] 175 | [...] 176 | ``` 177 | 178 | 179 | ## Project structure 180 | 181 | ``` 182 | ├── src 183 | │ ├── file01.coffee 184 | │ ├── file02.coffee 185 | │ └── ... 186 | ├── spec 187 | │ ├── file01.spec.coffee 188 | │ ├── file02.spec.coffee 189 | │ └── ... 190 | ├── package.json 191 | ├── karma.conf.coffee 192 | ├── .editorconfig 193 | └── .jshintrc 194 | ``` 195 | 196 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-typescript/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Jasmine & TypeScript 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-typescript-project 24 | version: (1.0.0) 25 | description: My TypeScript project 26 | entry point: (index.js) 27 | test command: karma start 28 | git repository: 29 | keywords: project, jasmine, karma, TypeScript 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-typescript-project", 36 | "version": "1.0.0", 37 | "description": "My TypeScript project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "karma start" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "jasmine", 45 | "karma", 46 | "TypeScript" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma & TypeScript 57 | 58 | ```shell 59 | npm install -D karma typescript karma-typescript-preprocessor 60 | # npm install -D karma typescript karma-typescript-preprocessor jasmine-core karma-jasmine karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init 79 | ``` 80 | 81 | Console output : 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > jasmine 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.ts 102 | WARN [init]: There is no file matching this pattern. 103 | > spec/**/*.ts 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.js". 117 | ``` 118 | 119 | 120 | ## karma.conf.js & TypeScript 121 | 122 | ```javascript 123 | [...] 124 | preprocessors: { 125 | '+(src|spec)/**/*.ts': ['typescript'] 126 | }, 127 | [...] 128 | // TypeScript preprocessor configuration 129 | typescriptPreprocessor: { 130 | // options passed to the typescript compiler 131 | options: { 132 | target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5' 133 | noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type. 134 | } 135 | }, 136 | [...] 137 | ``` 138 | 139 | 140 | ## Jasmine & TypeScript 141 | 142 | Get `jasmine.d.ts` file from [DefinitelyTyped - Jasmine](https://github.com/borisyankov/DefinitelyTyped/tree/master/jasmine). 143 | 144 | Add at the begin of each test: 145 | 146 | ````typescript 147 | /// 148 | ``` 149 | 150 | 151 | ## Run tests 152 | 153 | ```shell 154 | # stand-alone 155 | karma start 156 | # within NPM 157 | npm test 158 | ``` 159 | 160 | 161 | ## Install Karma Coverage 162 | 163 | ```shell 164 | # Coverage 165 | npm install -D karma-coverage 166 | ``` 167 | 168 | 169 | ## karma.conf.js & coverage 170 | 171 | Attention le preprocessor doit se situer **après** celui de Typescript car Istanbul ne sait pas instrumenter TypeScript. 172 | 173 | La couverture de code sera alors donner sur le code généré en JS au lieu du TypeScript. 174 | 175 | ```javascript 176 | [...] 177 | preprocessors: { 178 | 'src/**/!(*.test).ts': 'coverage' 179 | }, 180 | [...] 181 | reporters: ['dots', 'coverage'], 182 | [...] 183 | // Coverage Reporter configuration 184 | coverageReporter: { 185 | reporters: [ 186 | // File output 187 | { 188 | type: 'html', 189 | dir: 'coverage/', 190 | // supprime les dossiers spécifiques à chaque browser 191 | subdir: '.' 192 | }, 193 | // Console output 194 | { 195 | type: 'text' 196 | } 197 | ] 198 | }, 199 | [...] 200 | ``` 201 | 202 | 203 | ## Project structure 204 | 205 | ``` 206 | ├── src 207 | │ ├── file01.ts 208 | │ ├── file02.ts 209 | │ └── ... 210 | ├── spec 211 | │ ├── vendor 212 | │ │ └── jasmine.d.ts 213 | │ ├── file01.spec.ts 214 | │ ├── file02.spec.ts 215 | │ └── ... 216 | ├── package.json 217 | ├── karma.conf.js 218 | ├── .editorconfig 219 | └── .jshintrc 220 | ``` 221 | 222 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/lib/jasmine-2.3.4/boot.js: -------------------------------------------------------------------------------- 1 | /** 2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. 3 | 4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. 5 | 6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. 7 | 8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem 9 | */ 10 | 11 | (function() { 12 | 13 | /** 14 | * ## Require & Instantiate 15 | * 16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. 17 | */ 18 | window.jasmine = jasmineRequire.core(jasmineRequire); 19 | 20 | /** 21 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. 22 | */ 23 | jasmineRequire.html(jasmine); 24 | 25 | /** 26 | * Create the Jasmine environment. This is used to run all specs in a project. 27 | */ 28 | var env = jasmine.getEnv(); 29 | 30 | /** 31 | * ## The Global Interface 32 | * 33 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. 34 | */ 35 | var jasmineInterface = jasmineRequire.interface(jasmine, env); 36 | 37 | /** 38 | * Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. 39 | */ 40 | extend(window, jasmineInterface); 41 | 42 | /** 43 | * ## Runner Parameters 44 | * 45 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. 46 | */ 47 | 48 | var queryString = new jasmine.QueryString({ 49 | getWindowLocation: function() { return window.location; } 50 | }); 51 | 52 | var catchingExceptions = queryString.getParam("catch"); 53 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); 54 | 55 | var throwingExpectationFailures = queryString.getParam("throwFailures"); 56 | env.throwOnExpectationFailure(throwingExpectationFailures); 57 | 58 | /** 59 | * ## Reporters 60 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). 61 | */ 62 | var htmlReporter = new jasmine.HtmlReporter({ 63 | env: env, 64 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); }, 65 | onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); }, 66 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); }, 67 | getContainer: function() { return document.body; }, 68 | createElement: function() { return document.createElement.apply(document, arguments); }, 69 | createTextNode: function() { return document.createTextNode.apply(document, arguments); }, 70 | timer: new jasmine.Timer() 71 | }); 72 | 73 | /** 74 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. 75 | */ 76 | env.addReporter(jasmineInterface.jsApiReporter); 77 | env.addReporter(htmlReporter); 78 | 79 | /** 80 | * Filter which specs will be run by matching the start of the full name against the `spec` query param. 81 | */ 82 | var specFilter = new jasmine.HtmlSpecFilter({ 83 | filterString: function() { return queryString.getParam("spec"); } 84 | }); 85 | 86 | env.specFilter = function(spec) { 87 | return specFilter.matches(spec.getFullName()); 88 | }; 89 | 90 | /** 91 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. 92 | */ 93 | window.setTimeout = window.setTimeout; 94 | window.setInterval = window.setInterval; 95 | window.clearTimeout = window.clearTimeout; 96 | window.clearInterval = window.clearInterval; 97 | 98 | /** 99 | * ## Execution 100 | * 101 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. 102 | */ 103 | var currentWindowOnload = window.onload; 104 | 105 | window.onload = function() { 106 | if (currentWindowOnload) { 107 | currentWindowOnload(); 108 | } 109 | htmlReporter.initialize(); 110 | env.execute(); 111 | }; 112 | 113 | /** 114 | * Helper function for readability above. 115 | */ 116 | function extend(destination, source) { 117 | for (var property in source) destination[property] = source[property]; 118 | return destination; 119 | } 120 | 121 | }()); 122 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-karma-babel/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Jasmine & Babel 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-jasmine-project 24 | version: (1.0.0) 25 | description: My jasmine project 26 | entry point: (index.js) 27 | test command: karma start 28 | git repository: 29 | keywords: project, jasmine, karma, babel 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-jasmine-project", 36 | "version": "1.0.0", 37 | "description": "My jasmine project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "karma start" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "jasmine", 45 | "karma", 46 | "babel" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma & Babel 57 | 58 | ```shell 59 | npm install -D karma karma-babel-preprocessor 60 | # npm install -D karma karma-babel-preprocessor jasmine-core karma-jasmine karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init 79 | ``` 80 | 81 | Console output : 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > jasmine 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.js 102 | WARN [init]: There is no file matching this pattern. 103 | > spec/**/*.js 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.js". 117 | ``` 118 | 119 | 120 | ## karma.conf.js & Babel 121 | 122 | ```javascript 123 | [...] 124 | preprocessors: { 125 | '+(src|spec)/**/*.js': ['babel'] 126 | }, 127 | [...] 128 | // Babel preprocessor configuration 129 | babelPreprocessor: { 130 | options: { 131 | sourceMap: 'inline' 132 | }, 133 | filename: function (file) { 134 | return file.originalPath.replace(/\.js$/, '.es5.js'); 135 | }, 136 | sourceFileName: function (file) { 137 | return file.originalPath; 138 | } 139 | }, 140 | [...] 141 | ``` 142 | 143 | 144 | ## Run tests 145 | 146 | ```shell 147 | # stand-alone 148 | karma start 149 | # within NPM 150 | npm test 151 | ``` 152 | 153 | 154 | ## Install Karma Coverage 155 | 156 | ```shell 157 | # Coverage 158 | npm install -D karma-coverage isparta 159 | ``` 160 | 161 | 162 | ## karma.conf.js & coverage 163 | 164 | Attention le preprocessor doit se situer avant celui de Babel sinon la couverture de code se fait sur le code généré par Babel. 165 | 166 | ```javascript 167 | [...] 168 | preprocessors: { 169 | 'spec/**/*.js': ['babel'], 170 | 'src/**/!(*.spec).js': ['coverage', 'babel'] 171 | }, 172 | [...] 173 | reporters: ['dots', 'coverage'], 174 | [...] 175 | // Coverage Reporter configuration 176 | coverageReporter: { 177 | reporters: [ 178 | // sortie fichier 179 | { 180 | type: 'html', 181 | dir: 'coverage/', 182 | // supprime les dossiers spécifiques à chaque browser 183 | subdir: '.' 184 | }, 185 | // sortie console 186 | { 187 | type: 'text' 188 | } 189 | ], 190 | instrumenters: { 191 | isparta: require('isparta') 192 | }, 193 | instrumenter: { 194 | '**/*.js': 'isparta' 195 | } 196 | } 197 | [...] 198 | ``` 199 | 200 | Il faut modifier la configuration de Babel : 201 | 202 | ```javascript 203 | [...] 204 | // Babel preprocessor configuration 205 | babelPreprocessor: { 206 | options: { 207 | // sourceMap: 'inline' 208 | }, 209 | filename: function (file) { 210 | return file.originalPath.replace(/\.js$/, '.es5.js'); 211 | }, 212 | sourceFileName: function (file) { 213 | return file.originalPath; 214 | } 215 | }, 216 | [...] 217 | ``` 218 | 219 | 220 | ## Project structure 221 | 222 | ``` 223 | ├── src 224 | │ ├── file01.js 225 | │ ├── file02.js 226 | │ └── ... 227 | ├── spec 228 | │ ├── file01.spec.js 229 | │ ├── file02.spec.js 230 | │ └── ... 231 | ├── package.json 232 | ├── karma.conf.js 233 | ├── .editorconfig 234 | └── .jshintrc 235 | ``` 236 | -------------------------------------------------------------------------------- /groovy/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /java/java-graddle/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /js/with-mocha/mocha-karma-babel/how-to-build.md: -------------------------------------------------------------------------------- 1 | # Karma & Mocha & Babel 2 | 3 | 4 | ## Initiate NPM project 5 | 6 | ```shell 7 | npm init 8 | ``` 9 | 10 | Console output: 11 | 12 | ```shell 13 | This utility will walk you through creating a package.json file. 14 | It only covers the most common items, and tries to guess sensible defaults. 15 | 16 | See `npm help json` for definitive documentation on these fields 17 | and exactly what they do. 18 | 19 | Use `npm install --save` afterwards to install a package and 20 | save it as a dependency in the package.json file. 21 | 22 | Press ^C at any time to quit. 23 | name: (temp) my-mocha-project 24 | version: (1.0.0) 25 | description: My mocha project 26 | entry point: (index.js) 27 | test command: mocha test 28 | git repository: 29 | keywords: project, mocha, karma, babel 30 | author: you 31 | license: (ISC) 32 | About to write to ...\package.json: 33 | 34 | { 35 | "name": "my-mocha-project", 36 | "version": "1.0.0", 37 | "description": "My mocha project", 38 | "main": "index.js", 39 | "scripts": { 40 | "test": "mocha test" 41 | }, 42 | "keywords": [ 43 | "project", 44 | "mocha", 45 | "karma", 46 | "babel" 47 | ], 48 | "author": "you", 49 | "license": "ISC" 50 | } 51 | 52 | Is this ok? (yes) 53 | ``` 54 | 55 | 56 | ## Install Karma, Chai, Sinon & Babel 57 | 58 | ```shell 59 | npm install -D karma karma-babel-preprocessor chai karma-chai sinon karma-sinon 60 | # npm install -D karma karma-babel-preprocessor chai karma-chai sinon karma-sinon mocha karma-mocha karma-phantomjs-launcher phantomjs 61 | ``` 62 | 63 | 64 | ## Install Karma as command line tool 65 | 66 | ```shell 67 | # linux 68 | npm install -g karma 69 | # windows 70 | npm install -g karma-cli 71 | ``` 72 | 73 | 74 | ## Initiate Karma project 75 | 76 | ```shell 77 | # Initiate Karma 78 | karma init 79 | ``` 80 | 81 | Console output: 82 | 83 | ```shell 84 | Which testing framework do you want to use ? 85 | Press tab to list possible options. Enter to move to the next question. 86 | > mocha 87 | 88 | Do you want to use Require.js ? 89 | This will add Require.js plugin. 90 | Press tab to list possible options. Enter to move to the next question. 91 | > no 92 | 93 | Do you want to capture any browsers automatically ? 94 | Press tab to list possible options. Enter empty string to move to the next question. 95 | > PhantomJS 96 | > 97 | 98 | What is the location of your source and test files ? 99 | You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". 100 | Enter empty string to move to the next question. 101 | > src/**/*.js 102 | WARN [init]: There is no file matching this pattern. 103 | > test/**/*.js 104 | WARN [init]: There is no file matching this pattern. 105 | > 106 | 107 | Should any of the files included by the previous patterns be excluded ? 108 | You can use glob patterns, eg. "**/*.swp". 109 | Enter empty string to move to the next question. 110 | > 111 | 112 | Do you want Karma to watch all the files and run the tests on change ? 113 | Press tab to list possible options. 114 | > yes 115 | 116 | Config file generated at "...\karma.conf.js". 117 | ``` 118 | 119 | 120 | ## karma.conf.js & Mocha, Chai, Sinon 121 | 122 | ```javascript 123 | [...] 124 | frameworks: ['mocha', 'chai', 'sinon'], 125 | [...] 126 | ``` 127 | 128 | 129 | ## karma.conf.js & Babel 130 | 131 | ```javascript 132 | [...] 133 | preprocessors: { 134 | '+(src|test)/**/*.js': ['babel'] 135 | }, 136 | [...] 137 | // Babel preprocessor configuration 138 | babelPreprocessor: { 139 | options: { 140 | sourceMap: 'inline' 141 | }, 142 | filename: function (file) { 143 | return file.originalPath.replace(/\.js$/, '.es5.js'); 144 | }, 145 | sourceFileName: function (file) { 146 | return file.originalPath; 147 | } 148 | }, 149 | [...] 150 | ``` 151 | 152 | 153 | ## Run tests 154 | 155 | ```shell 156 | # stand-alone 157 | karma start 158 | # within NPM 159 | npm test 160 | ``` 161 | 162 | 163 | ## Install Karma Coverage 164 | 165 | ```shell 166 | # Coverage 167 | npm install -D karma-coverage isparta 168 | ``` 169 | 170 | ## karma.conf.js & coverage 171 | 172 | ```javascript 173 | [...] 174 | preprocessors: { 175 | 'test/**/*.js': ['babel'], 176 | 'src/**/!(*.test).js': ['coverage', 'babel'] 177 | }, 178 | [...] 179 | reporters: ['dots', 'coverage'], 180 | [...] 181 | // Coverage Reporter configuration 182 | coverageReporter: { 183 | reporters: [ 184 | // sortie fichier 185 | { 186 | type: 'html', 187 | dir: 'coverage/', 188 | // supprime les dossiers spécifiques à chaque browser 189 | subdir: '.' 190 | }, 191 | // sortie console 192 | { 193 | type: 'text' 194 | } 195 | ], 196 | instrumenters: { 197 | isparta: require('isparta') 198 | }, 199 | instrumenter: { 200 | '**/*.js': 'isparta' 201 | } 202 | } 203 | [...] 204 | ``` 205 | 206 | Il faut modifier la configuration de Babel : 207 | 208 | ```javascript 209 | [...] 210 | // Babel preprocessor configuration 211 | babelPreprocessor: { 212 | options: { 213 | // sourceMap: 'inline' 214 | }, 215 | filename: function (file) { 216 | return file.originalPath.replace(/\.js$/, '.es5.js'); 217 | }, 218 | sourceFileName: function (file) { 219 | return file.originalPath; 220 | } 221 | }, 222 | [...] 223 | ``` 224 | 225 | 226 | ## Project structure 227 | 228 | ``` 229 | ├── src 230 | │ ├── file01.js 231 | │ ├── file02.js 232 | │ └── ... 233 | ├── test 234 | │ ├── file01.test.js 235 | │ ├── file02.test.js 236 | │ └── ... 237 | ├── package.json 238 | ├── karma.conf.js 239 | ├── .editorconfig 240 | └── .jshintrc 241 | ``` 242 | -------------------------------------------------------------------------------- /js/with-jasmine/jasmine-htmlrunner/lib/jasmine-2.3.4/console.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008-2015 Pivotal Labs 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | function getJasmineRequireObj() { 24 | if (typeof module !== 'undefined' && module.exports) { 25 | return exports; 26 | } else { 27 | window.jasmineRequire = window.jasmineRequire || {}; 28 | return window.jasmineRequire; 29 | } 30 | } 31 | 32 | getJasmineRequireObj().console = function(jRequire, j$) { 33 | j$.ConsoleReporter = jRequire.ConsoleReporter(); 34 | }; 35 | 36 | getJasmineRequireObj().ConsoleReporter = function() { 37 | 38 | var noopTimer = { 39 | start: function(){}, 40 | elapsed: function(){ return 0; } 41 | }; 42 | 43 | function ConsoleReporter(options) { 44 | var print = options.print, 45 | showColors = options.showColors || false, 46 | onComplete = options.onComplete || function() {}, 47 | timer = options.timer || noopTimer, 48 | specCount, 49 | failureCount, 50 | failedSpecs = [], 51 | pendingCount, 52 | ansi = { 53 | green: '\x1B[32m', 54 | red: '\x1B[31m', 55 | yellow: '\x1B[33m', 56 | none: '\x1B[0m' 57 | }, 58 | failedSuites = []; 59 | 60 | print('ConsoleReporter is deprecated and will be removed in a future version.'); 61 | 62 | this.jasmineStarted = function() { 63 | specCount = 0; 64 | failureCount = 0; 65 | pendingCount = 0; 66 | print('Started'); 67 | printNewline(); 68 | timer.start(); 69 | }; 70 | 71 | this.jasmineDone = function() { 72 | printNewline(); 73 | for (var i = 0; i < failedSpecs.length; i++) { 74 | specFailureDetails(failedSpecs[i]); 75 | } 76 | 77 | if(specCount > 0) { 78 | printNewline(); 79 | 80 | var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + 81 | failureCount + ' ' + plural('failure', failureCount); 82 | 83 | if (pendingCount) { 84 | specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); 85 | } 86 | 87 | print(specCounts); 88 | } else { 89 | print('No specs found'); 90 | } 91 | 92 | printNewline(); 93 | var seconds = timer.elapsed() / 1000; 94 | print('Finished in ' + seconds + ' ' + plural('second', seconds)); 95 | printNewline(); 96 | 97 | for(i = 0; i < failedSuites.length; i++) { 98 | suiteFailureDetails(failedSuites[i]); 99 | } 100 | 101 | onComplete(failureCount === 0); 102 | }; 103 | 104 | this.specDone = function(result) { 105 | specCount++; 106 | 107 | if (result.status == 'pending') { 108 | pendingCount++; 109 | print(colored('yellow', '*')); 110 | return; 111 | } 112 | 113 | if (result.status == 'passed') { 114 | print(colored('green', '.')); 115 | return; 116 | } 117 | 118 | if (result.status == 'failed') { 119 | failureCount++; 120 | failedSpecs.push(result); 121 | print(colored('red', 'F')); 122 | } 123 | }; 124 | 125 | this.suiteDone = function(result) { 126 | if (result.failedExpectations && result.failedExpectations.length > 0) { 127 | failureCount++; 128 | failedSuites.push(result); 129 | } 130 | }; 131 | 132 | return this; 133 | 134 | function printNewline() { 135 | print('\n'); 136 | } 137 | 138 | function colored(color, str) { 139 | return showColors ? (ansi[color] + str + ansi.none) : str; 140 | } 141 | 142 | function plural(str, count) { 143 | return count == 1 ? str : str + 's'; 144 | } 145 | 146 | function repeat(thing, times) { 147 | var arr = []; 148 | for (var i = 0; i < times; i++) { 149 | arr.push(thing); 150 | } 151 | return arr; 152 | } 153 | 154 | function indent(str, spaces) { 155 | var lines = (str || '').split('\n'); 156 | var newArr = []; 157 | for (var i = 0; i < lines.length; i++) { 158 | newArr.push(repeat(' ', spaces).join('') + lines[i]); 159 | } 160 | return newArr.join('\n'); 161 | } 162 | 163 | function specFailureDetails(result) { 164 | printNewline(); 165 | print(result.fullName); 166 | 167 | for (var i = 0; i < result.failedExpectations.length; i++) { 168 | var failedExpectation = result.failedExpectations[i]; 169 | printNewline(); 170 | print(indent(failedExpectation.message, 2)); 171 | print(indent(failedExpectation.stack, 2)); 172 | } 173 | 174 | printNewline(); 175 | } 176 | 177 | function suiteFailureDetails(result) { 178 | for (var i = 0; i < result.failedExpectations.length; i++) { 179 | printNewline(); 180 | print(colored('red', 'An error was thrown in an afterAll')); 181 | printNewline(); 182 | print(colored('red', 'AfterAll ' + result.failedExpectations[i].message)); 183 | 184 | } 185 | printNewline(); 186 | } 187 | } 188 | 189 | return ConsoleReporter; 190 | }; 191 | -------------------------------------------------------------------------------- /php/with-atoum/tests/Infrastructure/Provider/ArrayDataProvider.php: -------------------------------------------------------------------------------- 1 | testedClass 15 | ->implements(DataProviderInterface::class); 16 | } 17 | 18 | public function testConstructor($assert, $data, $result) 19 | { 20 | $this 21 | ->assert($assert) 22 | ->given( 23 | $this->newTestedInstance($data) 24 | ) 25 | ->array($this->testedInstance->getData()) 26 | ->isEqualTo($result); 27 | } 28 | 29 | protected function testConstructorDataProvider() 30 | { 31 | return [ 32 | [ 33 | 'Test with empty array', 34 | [], 35 | [] 36 | ], 37 | [ 38 | 'Test with simple ordered array', 39 | [ 1, 2, 3 ], 40 | [ 41 | 0 => 1, 42 | 1 => 2, 43 | 2 => 3 44 | ] 45 | ], 46 | [ 47 | 'Test with simple associate array', 48 | [ 49 | 'A' => 1, 50 | 'B' => 2 51 | ], 52 | [ 53 | 'A' => 1, 54 | 'B' => 2 55 | ] 56 | ], 57 | [ 58 | 'Test with string', 59 | 'foo', 60 | [] 61 | ], 62 | [ 63 | 'Test with integer', 64 | 123, 65 | [] 66 | ] 67 | ]; 68 | } 69 | 70 | public function testHas($assert, $data, $id, $result) 71 | { 72 | $this 73 | ->assert($assert) 74 | ->given( 75 | $this->newTestedInstance($data) 76 | ) 77 | ->boolean($this->testedInstance->has($id)) 78 | ->isEqualTo($result); 79 | } 80 | 81 | protected function testHasDataProvider() 82 | { 83 | return [ 84 | [ 85 | 'Test with existing data', 86 | [ 87 | 'A' => 1 88 | ], 89 | 'A', 90 | true 91 | ], 92 | [ 93 | 'Test with non existing data', 94 | [ 95 | 'A' => 1 96 | ], 97 | 'B', 98 | false 99 | ], 100 | [ 101 | 'Test with existing data but null', 102 | [ 103 | 'A' => null 104 | ], 105 | 'A', 106 | true 107 | ] 108 | ]; 109 | } 110 | 111 | public function testGet($assert, $data, $id, $result) 112 | { 113 | $this 114 | ->assert($assert) 115 | ->given( 116 | $this->newTestedInstance($data) 117 | ) 118 | ->variable($this->testedInstance->get($id)) 119 | ->isEqualTo($result); 120 | } 121 | 122 | protected function testGetDataProvider() 123 | { 124 | return [ 125 | [ 126 | 'Test with ordered data', 127 | [ 1, 2, 3], 128 | 0, 129 | 1 130 | ], 131 | [ 132 | 'Test with associate array', 133 | [ 134 | 'A' => 1, 135 | 'B' => 2 136 | ], 137 | 'B', 138 | 2 139 | ] 140 | ]; 141 | } 142 | 143 | public function testGetNonExistantData() 144 | { 145 | $this 146 | ->given( 147 | $this->newTestedInstance() 148 | ) 149 | ->exception(function($atoum) { 150 | $atoum->testedInstance->get('foo'); 151 | }) 152 | ->isInstanceOf(DataProviderException::class) 153 | ->message 154 | ->isEqualTo('Data with key "foo" doesn\'t exists.'); 155 | } 156 | 157 | public function testSet($assert, $key, $data) 158 | { 159 | $this 160 | ->assert($assert) 161 | ->given( 162 | $this->newTestedInstance() 163 | ) 164 | ->if( 165 | $this->testedInstance->set($key, $data) 166 | ) 167 | ->variable($this->testedInstance->get($key)) 168 | ->isEqualTo($data) 169 | ; 170 | } 171 | 172 | protected function testSetDataProvider() 173 | { 174 | return [ 175 | [ 176 | 'Test with simple data', 177 | 'A', 178 | 'foo' 179 | ] 180 | ]; 181 | } 182 | 183 | public function testSetWithException($assert, $key, $message) 184 | { 185 | $this 186 | ->assert($assert) 187 | ->given( 188 | $this->newTestedInstance() 189 | ) 190 | ->exception(function($atoum) use ($key) { 191 | $atoum->testedInstance->set($key, 'foo'); 192 | }) 193 | ->message 194 | ->isEqualTo($message); 195 | } 196 | 197 | protected function testSetWithExceptionDataProvider() 198 | { 199 | return [ 200 | [ 201 | 'Test with null key', 202 | null, 203 | 'Key is null !' 204 | ], 205 | [ 206 | 'Test with array key', 207 | [ 1, 2, 3], 208 | 'Key is not a scalar value, array given.' 209 | ], 210 | [ 211 | 'Test with object key', 212 | new \stdClass(), 213 | 'Key is not a scalar value, object given.' 214 | ] 215 | ]; 216 | } 217 | 218 | } 219 | -------------------------------------------------------------------------------- /js/with-qunit/qunit-htmlrunner/lib/qunit-1.18.0.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * QUnit 1.18.0 3 | * http://qunitjs.com/ 4 | * 5 | * Copyright jQuery Foundation and other contributors 6 | * Released under the MIT license 7 | * http://jquery.org/license 8 | * 9 | * Date: 2015-04-03T10:23Z 10 | */ 11 | 12 | /** Font Family and Sizes */ 13 | 14 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { 15 | font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; 16 | } 17 | 18 | #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } 19 | #qunit-tests { font-size: smaller; } 20 | 21 | 22 | /** Resets */ 23 | 24 | #qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter { 25 | margin: 0; 26 | padding: 0; 27 | } 28 | 29 | 30 | /** Header */ 31 | 32 | #qunit-header { 33 | padding: 0.5em 0 0.5em 1em; 34 | 35 | color: #8699A4; 36 | background-color: #0D3349; 37 | 38 | font-size: 1.5em; 39 | line-height: 1em; 40 | font-weight: 400; 41 | 42 | border-radius: 5px 5px 0 0; 43 | } 44 | 45 | #qunit-header a { 46 | text-decoration: none; 47 | color: #C2CCD1; 48 | } 49 | 50 | #qunit-header a:hover, 51 | #qunit-header a:focus { 52 | color: #FFF; 53 | } 54 | 55 | #qunit-testrunner-toolbar label { 56 | display: inline-block; 57 | padding: 0 0.5em 0 0.1em; 58 | } 59 | 60 | #qunit-banner { 61 | height: 5px; 62 | } 63 | 64 | #qunit-testrunner-toolbar { 65 | padding: 0.5em 1em 0.5em 1em; 66 | color: #5E740B; 67 | background-color: #EEE; 68 | overflow: hidden; 69 | } 70 | 71 | #qunit-userAgent { 72 | padding: 0.5em 1em 0.5em 1em; 73 | background-color: #2B81AF; 74 | color: #FFF; 75 | text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; 76 | } 77 | 78 | #qunit-modulefilter-container { 79 | float: right; 80 | padding: 0.2em; 81 | } 82 | 83 | .qunit-url-config { 84 | display: inline-block; 85 | padding: 0.1em; 86 | } 87 | 88 | .qunit-filter { 89 | display: block; 90 | float: right; 91 | margin-left: 1em; 92 | } 93 | 94 | /** Tests: Pass/Fail */ 95 | 96 | #qunit-tests { 97 | list-style-position: inside; 98 | } 99 | 100 | #qunit-tests li { 101 | padding: 0.4em 1em 0.4em 1em; 102 | border-bottom: 1px solid #FFF; 103 | list-style-position: inside; 104 | } 105 | 106 | #qunit-tests > li { 107 | display: none; 108 | } 109 | 110 | #qunit-tests li.running, 111 | #qunit-tests li.pass, 112 | #qunit-tests li.fail, 113 | #qunit-tests li.skipped { 114 | display: list-item; 115 | } 116 | 117 | #qunit-tests.hidepass li.running, 118 | #qunit-tests.hidepass li.pass { 119 | visibility: hidden; 120 | position: absolute; 121 | width: 0px; 122 | height: 0px; 123 | padding: 0; 124 | border: 0; 125 | margin: 0; 126 | } 127 | 128 | #qunit-tests li strong { 129 | cursor: pointer; 130 | } 131 | 132 | #qunit-tests li.skipped strong { 133 | cursor: default; 134 | } 135 | 136 | #qunit-tests li a { 137 | padding: 0.5em; 138 | color: #C2CCD1; 139 | text-decoration: none; 140 | } 141 | 142 | #qunit-tests li p a { 143 | padding: 0.25em; 144 | color: #6B6464; 145 | } 146 | #qunit-tests li a:hover, 147 | #qunit-tests li a:focus { 148 | color: #000; 149 | } 150 | 151 | #qunit-tests li .runtime { 152 | float: right; 153 | font-size: smaller; 154 | } 155 | 156 | .qunit-assert-list { 157 | margin-top: 0.5em; 158 | padding: 0.5em; 159 | 160 | background-color: #FFF; 161 | 162 | border-radius: 5px; 163 | } 164 | 165 | .qunit-collapsed { 166 | display: none; 167 | } 168 | 169 | #qunit-tests table { 170 | border-collapse: collapse; 171 | margin-top: 0.2em; 172 | } 173 | 174 | #qunit-tests th { 175 | text-align: right; 176 | vertical-align: top; 177 | padding: 0 0.5em 0 0; 178 | } 179 | 180 | #qunit-tests td { 181 | vertical-align: top; 182 | } 183 | 184 | #qunit-tests pre { 185 | margin: 0; 186 | white-space: pre-wrap; 187 | word-wrap: break-word; 188 | } 189 | 190 | #qunit-tests del { 191 | background-color: #E0F2BE; 192 | color: #374E0C; 193 | text-decoration: none; 194 | } 195 | 196 | #qunit-tests ins { 197 | background-color: #FFCACA; 198 | color: #500; 199 | text-decoration: none; 200 | } 201 | 202 | /*** Test Counts */ 203 | 204 | #qunit-tests b.counts { color: #000; } 205 | #qunit-tests b.passed { color: #5E740B; } 206 | #qunit-tests b.failed { color: #710909; } 207 | 208 | #qunit-tests li li { 209 | padding: 5px; 210 | background-color: #FFF; 211 | border-bottom: none; 212 | list-style-position: inside; 213 | } 214 | 215 | /*** Passing Styles */ 216 | 217 | #qunit-tests li li.pass { 218 | color: #3C510C; 219 | background-color: #FFF; 220 | border-left: 10px solid #C6E746; 221 | } 222 | 223 | #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } 224 | #qunit-tests .pass .test-name { color: #366097; } 225 | 226 | #qunit-tests .pass .test-actual, 227 | #qunit-tests .pass .test-expected { color: #999; } 228 | 229 | #qunit-banner.qunit-pass { background-color: #C6E746; } 230 | 231 | /*** Failing Styles */ 232 | 233 | #qunit-tests li li.fail { 234 | color: #710909; 235 | background-color: #FFF; 236 | border-left: 10px solid #EE5757; 237 | white-space: pre; 238 | } 239 | 240 | #qunit-tests > li:last-child { 241 | border-radius: 0 0 5px 5px; 242 | } 243 | 244 | #qunit-tests .fail { color: #000; background-color: #EE5757; } 245 | #qunit-tests .fail .test-name, 246 | #qunit-tests .fail .module-name { color: #000; } 247 | 248 | #qunit-tests .fail .test-actual { color: #EE5757; } 249 | #qunit-tests .fail .test-expected { color: #008000; } 250 | 251 | #qunit-banner.qunit-fail { background-color: #EE5757; } 252 | 253 | /*** Skipped tests */ 254 | 255 | #qunit-tests .skipped { 256 | background-color: #EBECE9; 257 | } 258 | 259 | #qunit-tests .qunit-skipped-label { 260 | background-color: #F4FF77; 261 | display: inline-block; 262 | font-style: normal; 263 | color: #366097; 264 | line-height: 1.8em; 265 | padding: 0 0.5em; 266 | margin: -0.4em 0.4em -0.4em 0; 267 | } 268 | 269 | /** Result */ 270 | 271 | #qunit-testresult { 272 | padding: 0.5em 1em 0.5em 1em; 273 | 274 | color: #2B81AF; 275 | background-color: #D2E0E6; 276 | 277 | border-bottom: 1px solid #FFF; 278 | } 279 | #qunit-testresult .module-name { 280 | font-weight: 700; 281 | } 282 | 283 | /** Fixture */ 284 | 285 | #qunit-fixture { 286 | position: absolute; 287 | top: -10000px; 288 | left: -10000px; 289 | width: 1000px; 290 | height: 1000px; 291 | } 292 | --------------------------------------------------------------------------------