mardi 1 septembre 2020

Integration test project should be in client side or component side?

I am facing some confusion in setup the integration test project.

I have component based project which is consumed by Client means we are going to integrate the component to client.

So as we integrating component to client where we have to place integration test project ?

how to redirect the traffic through ZAP for mobile applications security testing using ZAP

I have followed the steps which is in this website Click here for websitefor andriod setup. Websites or URL's are displaying under Sites tree in ZAP, but when i used any application those services are not displayed under sites tree. Can't we catch the API's or URL's in mobile application using ZAP tool??? Does anything need to do from my side or anything wrong i have done??? Correct me if i am wrong!!!

Wich strategy to implement testing in React-Redux app

I'm a french junior developper on react-redux and I just started a new job in a tiny company (5 persons, 2 developpers). I work with a senior developper and we are looking for testing practices to apply tests on our app. We already have so informations and we already know some technologies : Jest and React testing library ; and we would apply Test Driven Developpement in our futur projects. But we feel lost about the strategy to implement it, about unit test or integration test, about the time that we could save with test or not, about what we have to test in priority or not, etc. Open to discuss and I could explain more in details by email if you want. Thank you so much !

TypeError: this.datasource.getProducts is not a function

I am using the latest version of angular9 and am trying to write a unit test to test Service that gets a list of products.

When running ng test in visual code terminal it fails for the test: "TypeError: this.datasource.getProducts is not a function" with error :

after doing ng serve I get an error in console as shown in image.

As shown in the above image, the product.repository.ts code given below.

product.repository.ts

import { Product } from './product.model';
import { Injectable } from '@angular/core';
import { StaticDataSource } from './static.datasource';

@Injectable()
export class ProductRepository {

  private products: Product[] = [];
  private categories: string[] = [];

  constructor(private datasource: StaticDataSource) {
      this.datasource.getProducts().subscribe( data =>
        {
          this.products = data;
          this.categories = data.map(p => p.category)
          // tslint:disable-next-line: triple-equals
          .filter((c, index, array) => array.indexOf(c) == index).sort();
        });
  }

  getProducts(category: string = null): Product[]
  {
    return this.products
    .filter(p => category == null || category == p.category);
  }

  getProduct(id: number): Product
  {
    return this.products.find(p => p.id == id);
  }

  getCategories(): string[] {
    return this.categories;
  }

}

Below is the code of static.datasource.ts

static.datasource.ts

import { Injectable } from "@angular/core";
import { Product } from './product.model';
import { Observable, from } from 'rxjs';
import { Order } from './order.model';

@Injectable()
export class StaticDataSource {

  private products: Product[] = [
    new Product(1, 'Flyraom Lace up shoe', 'Category 1', 'Sneaker Shoe (Category 1)', 100),
    new Product(2, 'T-Shirt', 'Category 1', 'Sports T-shirt High Quality (Category 1)', 90),
    new Product(3, 'TR Trail Shoe', 'Category 1', 'Running Shoe (Category 1)', 99),
    new Product(4, 'Cooler', 'Category 1', 'High Quality Cooler (Category 1)', 50),
    new Product(5, 'Graphic T-Shirt Grey L', 'Category 1', 'Cotton T-shirt (Category 1)', 60),
    new Product(6, 'Euphoria EDP 100 ml', 'Category 2', 'Liquid Amber, Black Violet, Cream, Mahogany Wood (Category 2)', 150),
    new Product(7, 'Eternity Moment EDP 100 ml', 'Category 2', 'Brazillian Rose Wood, Cashmere Wood, Musk (Category 2)', 80),
    new Product(8, 'In Red EDT 100 ml', 'Category 2', 'Lily, Jasmine, Violet Leaf, Rose, Blackcurrant (Category 2)', 90),
    new Product(9, 'Flower Pink EDT 100 ml', 'Category 2', 'Othmani Roses', 99),
    new Product(10, 'Musk EDC 59 ml', 'Category 2', 'Musk EDC 59 ml', 88),
    new Product(11, 'Shampo', 'Category 3', 'Favourite Shampoo', 188),
    new Product(12, 'Biscuit', 'Category 4', 'Crunchy Biscuit', 88),
    new Product(13, 'Chips', 'Category 5', 'Salted & crunchy tasty Chips', 150)
  ];

  getProducts(): Observable<Product[]> {
    return from([this.products]);
  }

  saveOrder(order: Order): Observable<Order>
  {
    console.log(JSON.stringify(order));
    return from([order]);
  }
}

Test performance of mobile application

is there any open source tool(framework) for mobile performance testing available? Some example of test that i want to make: RAM is full Disable the camera make storage full

thx

Are Characterization (Golden Master/Snapshot) tests supposed to be human readable?

I am trying to write characterization tests, in order to quickly put a legacy system to a test harness.

I was not able to find many examples with production code. The examples I find are small programs.

An example by an author of Working Effectively with Legacy Code implements them as unit tests.

It's nice because it's human-readable and help you understand the code. However, I think it would work for small programs in the example, but the system I am trying to test is a pretty complex API client.

Other examples store the inputs and outputs in files and read them to compare the results with the 'snapshots'.

Some examples are VCR, Approval Tests, Golden Master Testing

I feel like this allows the test input to be generated, and suitable for testing a large set of inputs.

However, for some reason it feels more high-level than unit testing, and not very human-readable.

Are these tests supposed to be part of your unit test suite, or are they supposed to be complements to unit tests?

In other words, should I sample some characteristic test inputs and write characterization tests as unit tests, but using the actual output from the code to 'lock down' the existing behaviors, and trying to make it readable? Or should I treat characterization tests as a complement to unit tests? If so, what should I focus on in my unit tests?

Testcafe: How to wait for the remote runner to be waiting/accepting connections before launching my browser?

First and foremost, the "remote" function of Testcafe is easily one of the best and most portable browser testing implementations I have ever come across; excellent work to the team developing it.

When I run npx testcafe remote ./tests --ports 5567,5568

The runner will notify me that it's listening on http://localhost:5567/browser/connect. Fantastic, now I want to launch my browser and navigate to this URL.

My browser might be a headless browser inside a docker container, or it could be a remote server running MacOS - regardless of its location, the remote needs to be issued commands after the test runner is ready and accepting connections.

Is there an endpoint like /ping or something that I can send a request to that will notify me of the test runner's active status?

npx concurrently \
  "npx wait-on http://localhost:5567/ping && remote-browser-util IOS_SAFARI http://localhost:5567/browser/connect" \
  "npx testcafe remote ./tests --ports 5567,5568"