Skip to main content
Commonmark migration
Source Link
  1. Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

  2. Should I write integration test and unit test together?

  3. How can I write unit test for my method?

    Also something seems incorrect to me.

  4. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  5. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

Also something seems incorrect to me.

  1. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  2. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

  1. Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

  2. Should I write integration test and unit test together?

  3. How can I write unit test for my method?

Also something seems incorrect to me.

  1. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  2. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

  1. Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

  2. Should I write integration test and unit test together?

  3. How can I write unit test for my method?

    Also something seems incorrect to me.

  4. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  5. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

1- Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

2- Should I write integration test and unit test together?

3- How can I write unit test for my method?

  1. Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

  2. Should I write integration test and unit test together?

  3. How can I write unit test for my method?

Also something seems incorrect to me.

4- My tests are depend on eachother. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

5- My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

  1. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  2. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

1- Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

2- Should I write integration test and unit test together?

3- How can I write unit test for my method?

Also something seems incorrect to me.

4- My tests are depend on eachother. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

5- My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

  1. Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

  2. Should I write integration test and unit test together?

  3. How can I write unit test for my method?

Also something seems incorrect to me.

  1. My tests are depend on each other. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

  2. My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.

Source Link

Why should I write unit test for my example instead of (or with) my integration test

I have a repository function on my repository layer. I use sequelize as data access. I will write tests for my function.

Here is the logic I want in English:

  • My function should save a user to database by using the email and password
  • My function should return an object representation of my created user.

For the logic I write the code below.

const UserModel = require('../models/user'); exports.create = async (email, password) => { const createdUser = await UserModel.create({ email, password }); return createdUser.toJSON(); }; 

So, I am planning to write integration tests. I will write some tests as below.

const userRepository = require('./repositories/user'); const userModel = require('./model/user'); const chai = require('chai'); it('should create a user by using the correct email and password', async () => { const email = '[email protected]'; const password = 'test@Pass123'; const createdUser = await userRepository.create(email, password); const userInDb = userModel.findOne( { id = createdUser.id } ); chai.expect(userInDb.email).to.be.equal(email); chai.expect(userInDb.password).to.be.equal(password); }); it('should return object representation of created user', async () => { const email = '[email protected]'; const password = 'test@Pass123'; const createdUser = await userRepository.create(email, password); chai.expect(typeof userInDb).to.be.equal('object'); }); 

So I have several questions.

1- Isn't the test enough? Should I write unit test for it? Or what are the benefits of having unit test for my method with or without my integration test.

2- Should I write integration test and unit test together?

3- How can I write unit test for my method?

Also something seems incorrect to me.

4- My tests are depend on eachother. Like, if my should return object test fails my other test could fail. Because i depent my return result will be an object in first test.

5- My tests depend on the package I use. My repository method uses sequelize for the logic. However if I change sequelize ORM with another ORM. I have to change my tests as well.