mercredi 29 juin 2016

How to know which unit tests are calling which functions in code coverage?

I am working on a javascript project. Using mocha for unit tests and istanbul for code coverage. In code coverage I want to know which functions from the source code each test is calling. Is it possible? If yes, how?

How can i run a a unit Test in Apache Camel

I want to know the comand line in maven to run unit tests for Apache Camel. Any help please? Regard

How to write unit tests in C

I need to write a simple unit test that executes on a given .c file. I can't seem to find simple explanations or examples on the web to help me accomplish this. I've seen examples where unit testing frameworks such as cUnit are used.. but is this a necessity? Also, I need the unit test to be executable without using any IDE.

How to get header values in laravel testing

This is how i get response in test Case

$response = $this->call('POST','/api/auth/login',['username'=>'xx','password'=>'xxx'], [/* cookies */], [/* files */], ['HTTP_ClientSecret' => 'xxxx']);

Then we can get response content by like this

$response->getContents()

i want to know how to get response header data ?

Angular 1.5 unit test controller that requires parent component's controller

I'm trying to unit test a (child) controller of an AngularJS 1.5 (with Webpack) component that requires a parent component and a controller from another module.

Child controller structure:

function ChildController () {
  var vm = this;

  vm.searchText = '';

  vm.submit = function() {
    var data = {};
    data['srch'] = vm.searchText;
    vm.parentCtrl.submitTextSearch(data);
  };
}

module.exports = ChildController;

Child component:

var template = require('./child.html');
var controller = require('./child.controller');

var childComponent = {
  require: {
    parentCtrl: '^parent'
  },
  template: template,
  controller: controller,
  controllerAs: 'vm'
};

module.exports = childComponent;

So what I would like to do is to mock out the parentCtrl that's required in the childController's submit()-function. I've been unable to find how to actually do this. I've found some similar child-parent directive solutions and tried those, e.g. injecting the parent controller through fake html-element as described in this child-parent directive example and basically the same stackoverflow solutions with no results. My problems differs at least in the fact that the child and parent controller are in different modules. And I suppose scope-tricks are not that much Angular 1.5-style?

The skeleton of my Jasmine test without my failed mock attempts:

describe('child component', function() {
  describe('child controller', function() {
    var controller;
    beforeEach(angular.mock.module('child'));
    beforeEach(inject(function(_$componentController_) {
      controller = _$componentController_('child');
    }))
    it('should work', function() {
      controller.searchText = "test";
      controller.submit();
    })
  })
})

That results in TypeError: Cannot read property 'submitTextSearch' of undefined. What exactly should I do to mock the parent controller out? With my limited experience in Angular I'm out of ideas.

Can you stop an MUnit test part way through a flow?

I am writing an MUnit test to test a sub-flow is called but once the sub-flow has been called the test tries to route through the rest of the flow. Without mocking various processors this means the test will fail.

Is it possible to stop a test when it reaches a certain processor? I.e. when message processor matches X Stop test?

ODOO [V8] Unit Tests

I'm actually trying to run the unittests I've created thanks to Odoo's documentation.

I've built my module like this :

module_test
- __init__.py
  __openerp.py__
... 
- tests
   __init__.py
   test_1.py

Inside 'module_test/tests/init.py', I do have "import test_1" Inside, 'module_test/tests/test_1.py", I do have : "import tests + a test scenario I've written.

Then I launch the command line to run server, and I add : '-u module_test --log-level=test --test-enable' to update the module and activate the tests run

The shell returns : "All post-tested in 0.00s, 0 queries". So in fact, no tests are run.

I then added a syntax error, so the file can't be compiled by the server, but shell returned the same sentence. It looks like the file is ignored, and the server is not even trying to compile my file... I do not understand why ?

I've checked some Odoo source module, the 'sale' one for example. I've tried to run sale tests, shell returned the same value than before. I added syntax error inside sale tests, shell returned the same value again, and again.

Does anyone have an idea about this unexpected behavior ?

Thank you...!