Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Can I test flow for an entire scenario using unit test cases or do I have to do that manually only

 
Ranch Hand
Posts: 2550
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The application reads input data from Source1 and Source2 and in the Result (JSON format ), populates a field success as True when both files are present, and success as False when atleast one file is not present.

It has methods such as readFromSource1 and readFromSource2 and processData, writeOutput. When writing unit test cases, I can implement methods like test_readFromSource1 and test_readFromSource2, test_processData and test_writeOutput.

This can be used to test individual methods which are parts of functionality but how to test the overall flow which is like in below scenarios :

Scenario 1: Put sample files in both sources.
Expected output : the success field in the JSON output should be True.

Scenario 2: Put file only in source1 and not in source2.
Expected output : the success field should be false.



I can test individual methods using test methods but is there way to test the entire flow of a particular scenario using a test case ?
Or do I have to test this manually only by running the program and checking the value of success field and then record these results for each scenario in say a word document.?

Thanks


 
Saloon Keeper
Posts: 1672
61
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am reading a lot about Testing Best Practices right now.

There are many books and several great ones covering these areas.

However, I also am liking this blog post series, and, hey, it is free:
https://defragdev.com/blog/2012/10/24/the-fundamentals-of-automated-testing-series.html

You might gain a lot from these, as they go back to the fundamentals of what writing good tests looks like.

It is fairly basic, and doesn't get too much into the details of any specific testing framework, but general principles of "What should the tests themselves look like?"

I think it is very clearly written.

If you take a look, let me know what you think of them.
 
Jesse Silverman
Saloon Keeper
Posts: 1672
61
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This (13-year-old!) post I just read today discusses the issue of what a Unit test is, and the advantages and disadvantages of writing Unit tests that are really more like functional or integration tests:

http://misko.hevery.com/2008/11/17/unified-theory-of-bugs/

The short answer is that yes you can, but there are some pitfalls or disadvantages.

I have indeed heard people say in real life that they can't do some re-factoring because it would break too many of their tests -- this is covered in that post.
 
Saloon Keeper
Posts: 24595
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Monica Shiralkar wrote:
This can be used to test individual methods which are parts of functionality but how to test the overall flow which is like in below scenarios ...



Testing the "overall flow" is what we call Integration Testing.

And yes, with JUnit, I often write Integration Tests as though they were Unit tests. Although at that level, I not infrequently use mocking frameworks to substitute for units that are too complex or delicate to run directly. Including mocking cases where the unit would have failed but I want to see how the higher-level code handles the failure. Without sabotaging the actual "failing" unit just to test.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic