New answers tagged

1

End-To-End tests have the following benefits They are very close to what the end user sees (often they directly test what the end user sees). They can directly test the fitness for purpose for the product user. They test thousands of lines of code per test They test the environment the product is deployed into So they do a couple things unit tests can't do,...


5

No, it is not a good approach. It is actually a terrible and common one. I would say it is a testing anti-pattern. End-to-End tests like you describe are high-effort, low-value and have high risk of breaking when making code changes. The main issue here is that lots of software has it's tests written after the coding is complete, and adding stable and fast ...


2

Given what you said, what I'd do is probably to send an interrupt (Ctrl+C) when the program hangs. I don't know about C#, bit in many of the languages I've used, this would raise an exception and an uncaught exception would normally end up with printing stack trace, which would give you a hint in where the code was blocking before the interrupt. If the code ...


1

Spring is not needed. You can create your tests with JUnit (As example) or another framework that let you mock elements. You only need to prepare your code to be tested. Maybe using JUnit inyection with annotations, parametrized constructor or setters to your class attributes.


0

My suggestion is to use a state-based testing approach: GIVEN We have the test DB in a known state WHEN The service is called with arguments X THEN Assert that the DB has changed from its original state to the expected state by calling read-only repository methods and checking their returned values Doing that way, you don't rely on any internal ...


3

Your question is confusing! The simple idea is that you should be able to trace a test back to a requirement. Otherwise why are you testing unrequired behaviour! Obviously in practice, no one writes requirements as detailed as their unit tests end up being. ie "The Addition Class will have a function Add() which shall add two ints together and return ...


1

By exposing TcpListener.Pending() on my APIServer, I was able to resolve this. APIServer.cs TcpListener server; public bool Pending { get { return server.Pending(); } } Unit Test [TestMethod] public async Task Start_TwoConnections_ClientsIsTwo() { ...


1

"The environment" usually has the same interface as a Map/Dictionary, or a lookup function -- you pass in a string, you get a string returned. // getenv: String -> String String path = System.getenv("PATH") My first choice is generally to run the tests in the correctly specified environment. After all, that's what the environment is for. But if I need ...


1

What do you want to verify in your test? If you want to verify that the Access-Control-Allow-Origin header is correctly filled according to the environment you are running in, then you should exactly read the expected value from the dotenv file, so you can know that its value is filled in correctly in the header. You would need a proper review process to ...


3

Brevity eludes me. I was commenting on randomized data driven tests and just wanted to keep going. For the case at hand, with only four possible input points. I agree on enumerating all posilibities. However, this is a simple case. I really want to point out that randomized data driven tests are useful. They have the potential to express the behaviour of ...


11

You have to test all the scenarios which are defined in your acceptance criteria. When you have an array of options like this I would use Data driven tests [TestCase("admin","public",true)] [TestCase("normal","public",true)] [TestCase("admin","private",true)] [TestCase("normal","private",false)] public void CanFileOpen(user,file,expected) { var actual ...


1

Assertions to me were always about documenting my assumptions related to the functioning of an algorithm. They communicate that, at this point, I’m asserting something should be true—likely, it’s a property I can prove to be true of a functioning implementation. For example, in a Semaphore implementation, I might have asserts that the value is never below ...


7

Purists won't call any test a "unit test" which involves a database. Other purists won't call a test an "integration test" when there are not at least two components involved (and a platform like the SQL engine of the DB usually does not count as a component). And some not so puristic people call everything a unit test which gets started by an automatic ...


0

A parser is a syntax-directed translator that converts a set of input words conforming to a base grammar to output "words", the words normally taking the form of a sequence of actions. Reverse the parser. Instead of it recognizing a base language and producing outputs for the input words it recognizes; have it generate the words of the base language and ...


Top 50 recent answers are included