Is it good or not have connection between it()?

王如锵

I am using mocha as test framework in my project.When I write unit test,I prefer to:

describe('cooperation', () => {
  describe('create cooperation', done => {
    it('should create a cooperation between A and B', done => {
      //make a post request to create a cooperation between A and B
      //res.body.should.deepEqual({/*cooperation object*/})
      done();
    });
  });

  describe('get cooperation', done => {
    before(done => {
      //clear any cooperation in database
      //initital cooperation between A and B by fixture tool
      done();
    });

    it('get A's partner', done => {
      //make a get request to get cooperation of A
      //res.body should have B
    });
  });
});

But my workmates prefer to:

describe('cooperation', () => {
  it('should create a cooperation between A and b', done => {
    //make a post request to create a cooperation between A and B
    //res.body.should.deepEqual({/*cooperation object*/})
    done();
  });

  it('get A's partner', done => {
    //make a get request to get cooperation of A
    //res.body should have B
  });
});

I want to know which is better and why?

nhaa123

I'd go with your team-mates. In my opinion, your style has non-necessary bloat and has worse readability compared to the other one. I think you should ask yourself, with your approach, that what do you expect to achieve more that is better than the other one?

Keep your tests simple and clean.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

"Good" Ethernet cable, no connection between 2 switches

From Java

Would it be possible to have multiple database connection pools in rails to switch between?

From Dev

Checking a good connection in Android

From Dev

How do I pass values between cards in Java CardLayout....this time i have given a good example

From Dev

A good way to corrupt TCP connection

From Dev

Is this a good way to dispose sql connection?

From Dev

Is it a good practice to have trim in setter?

From Dev

Is it good to have main controller in Angular?

From Dev

Is it a good practice to have trim in setter?

From Dev

Resize Thumb to have good quality

From Dev

have connection but no internet

From Dev

Is holding a java JMX connection open a good idea

From Dev

Is it good or bad to store the DB connection details with define()?

From Dev

How to verify is there is a good internet connection in C#?

From Dev

MongoDB - open and close connection - advise for good practice

From Dev

What is a good linux os to have that focuses on becoming a good system admin?

From Dev

In Node, what is a good way to create a http connection with a 'wait for connection' timeout

From Dev

Connection between phpstorm and xdebug

From Dev

connection between 2 namespaces

From Dev

Ethernet connection between buildings

From Dev

Connection between jmonkey and netbeans

From Dev

Connection between UPS and server

From Dev

Connection between Unity and Cesium

From Dev

Connection not close between SqlCommand

From Dev

Connection between 2 components

From Dev

Is it good practice to have multiple data contexts?

From Dev

Is it good practice to have lots of if else condition?

From Dev

Is it good programming to have a return type of Exception?

From Dev

Is it a good practice to have config in Redux store?

Related Related

  1. 1

    "Good" Ethernet cable, no connection between 2 switches

  2. 2

    Would it be possible to have multiple database connection pools in rails to switch between?

  3. 3

    Checking a good connection in Android

  4. 4

    How do I pass values between cards in Java CardLayout....this time i have given a good example

  5. 5

    A good way to corrupt TCP connection

  6. 6

    Is this a good way to dispose sql connection?

  7. 7

    Is it a good practice to have trim in setter?

  8. 8

    Is it good to have main controller in Angular?

  9. 9

    Is it a good practice to have trim in setter?

  10. 10

    Resize Thumb to have good quality

  11. 11

    have connection but no internet

  12. 12

    Is holding a java JMX connection open a good idea

  13. 13

    Is it good or bad to store the DB connection details with define()?

  14. 14

    How to verify is there is a good internet connection in C#?

  15. 15

    MongoDB - open and close connection - advise for good practice

  16. 16

    What is a good linux os to have that focuses on becoming a good system admin?

  17. 17

    In Node, what is a good way to create a http connection with a 'wait for connection' timeout

  18. 18

    Connection between phpstorm and xdebug

  19. 19

    connection between 2 namespaces

  20. 20

    Ethernet connection between buildings

  21. 21

    Connection between jmonkey and netbeans

  22. 22

    Connection between UPS and server

  23. 23

    Connection between Unity and Cesium

  24. 24

    Connection not close between SqlCommand

  25. 25

    Connection between 2 components

  26. 26

    Is it good practice to have multiple data contexts?

  27. 27

    Is it good practice to have lots of if else condition?

  28. 28

    Is it good programming to have a return type of Exception?

  29. 29

    Is it a good practice to have config in Redux store?

HotTag

Archive