Saturday, June 15, 2019

Sinon Spy vs Stub vs Mock

Many times we thought about that questions, so when should use what

Basic understanding:

When use what:
- Spy: when you want to verify REAL code behavior.
- Stub = Spy + customize behavior of target function by UT code.
- Mock = spy + stub + predefined expectation

OK fine, it is what mentioned document said :)

I just would make something more clear
- Spy and Stub is used only when you have the reference to object which will be faked
- Mock is used for case you do not have the reference to faking object
For example:
- You want to fake behavior of a nested new Object.
- You want to fake behavior of a nested service

Saturday, November 3, 2018

Promise

var promise1 = new Promise(function(resolve, reject) {
  setTimeout(function() {
    console.log("I am resolving"); 
    resolve('foo');
  }, 300);
  console.log("Just inited me, not yet resolved");
});
var pro2 = Promise.resolve().then((val) => {
  console.log("Calling promise");
  return promise1.then(function(val1) {
    console.log("Promise was resolved and returned value");
    return val1 ;
  });
});
pro2.then((val) => {
  console.log(val);
});

Note: the then will be called right after the resolve is invoked

Saturday, June 9, 2018

Docker CICD

Full testing project with Docker and CICD

https://github.com/lapth/test_docker_cicd

Friday, June 8, 2018

Java Jacoco Code coverage Powermock Mockito

Java Jacoco Powermock Mockito Maven JDK 1.8 Tested

https://github.com/lapth/powermock-examples-maven/tree/master/jacoco-offline

Java Jacoco Powermock Mockito Ant JDK 1.8 Tested

https://github.com/lapth/jacoco/tree/master/org.jacoco.examples.ant

https://github.com/lapth/jacoco/tree/master/org.jacoco.examples.ant.test

Wednesday, April 18, 2018

Redhat 7 - create new REPO from ISO

1) su -

2) cd /
3) mkdir /cdrom
4) mount /dev/sr0 /cdrom
=> mkae sure the RHEL 7.5 iso is in cdrom 0

5) cd /etc/yum.repos.d/
6) mv redhat.repo redhat.repo_bk
7) vi dvd.repo

[dvd-source]
name=RHEL 7.5
baseurl=file://cdrom
enabled=1
gpgcheck=0


8) yum repolist
=> should see the RHEL 7.5 now