testing – What do I call “unit tests” that are specifically developed during tinkering

Are these just throw-away code?

If these tests are not specifically designed for describing/asserting behavior of your application, in my opinion they should not be committed to the application repository. The cognitive overhead of developers figuring out what the tests are for and maintaining them would offset the minimal value they add. The test suite in its entirety should be descriptive of the behavior of the application, distinct from any module testing/learning exercises.

However, that does not mean that you necessarily have to throw them away (though I myself wouldn’t keep them for long). If you really want to keep the tests, but want to have them uncommitted, you could add a directory to your application repo and add that directory to your VCS exclusion list (e.g. .gitignore). That gets into your naming question; if I went that route, I would likely call this directory ignored, sandbox, test_debug or something like that, perhaps with a README explaining what the directory is for.

Better still, you could create a separate test repository (possibly a fork of your application repo) that makes clear the fact that these tests are just for getting familiar with the modules. That way you can keep the tests in VCS without having them directly associated with your real application and its test suite.

unit testing – Test driven development on front end?

When reading through internet, I’ve seen people are really into testing the front end applications. Some of them also say that they will never hire someone on front end who doesn’t have testing experience.

I understand that testing is necessary when dealing with huge amount of computation, logic and intertwined modules, which is most of the time not the case with front end development. The project I’m working on will have a couple of modules like that, and I would write the tests for that, but what to do with the rest of the app?

For example my current task is to create an AuthGuard service, and my project lead explicitly said that I need to write tests for it. While looking into it I found so many examples that are useless in my opinion.

For example I came across this function:

canActivate(): Observable<boolean> | Promise<boolean> | boolean {
  if (this.authService.isLoggedIn()) {
    return true;
  } else {
    return false;

being tested this way:

it('should return true for a logged in user', () => {
  authService = { isLoggedIn: () => true };
  router = new MockRouter();
  authGuard = new AuthGuard(authService, router);


Well, no way, Sherlock! Obviously it’s going to return true when there is an if statement, because that is how if statements work. And this is not the worse I’ve seen. I’ve seen a person creating a mock service, and mock api call with the same data and comparing the two.

I’m writing to check if there is something wrong with majority of our industry, or it just could be me? Did the test driven development gain too much attention and everyone is writing articles about how to do it while not mentioning that maybe we don’t need it?

linear algebra – How to find unit vector with a positive first component?

Let $R^4$ have the Euclidean inner product. Find a unit vector with a positive first component that is orthogonal to all three of the following vectors.

u $= (1,-1,3,0)$, v $= (6,1,0,1)$, w $= (1,0,7,1)$

I keep getting $(-14, -77,-21,11)$ but obviously that is not a vector with positive first component. Can anyone show me how this is done?

unit testing – Should you write integration tests at every level?

You should write enough tests so that if, say, function3 breaks it wont take long to realize that the bug is in function3.

It’s good to have a test exercising every public interface if for no better reason then it documents how to use the interface. But remember, the main value of tests is that they help you fix things. Write tests that make things easy to fix.

I’m not going to argue over whether you call them unit or integration tests. Just please separate the slow tests from the fast tests. It’s nice to not have to run them together every time.

java – Multiple Interstitial Ad unit in all activities

Recently, I’ve received an email from Google AdMob telling me that my Ads serving has been limited due to invalid traffic, in my app I use only a one interstitial Ad unit for all activities, and I show the ad as below :

public class AdmobHelper {

private InterstitialAd mInterstitialAd;
private AdRequest mAdRequest;

public AdmobHelper(Activity activity) {
    mAdRequest = new AdRequest.Builder().build();
    mInterstitialAd = new InterstitialAd(activity);

public void showInterstitial() {
    mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {

It’s possible the issue happened because I use one Ad unit in all activities?

simplifying expressions – Need help understanding the results of the unit function

I want to get Limit of the following function at $Tto 0$.
Eig=frac{8 (eta +J sinh (2 beta eta ) sinh (2 beta J)+eta cosh (2 beta eta ) cosh (2 beta J))}{eta Z^2}

where $Z=2 (cosh (2 beta eta )+cosh (2 beta J))$, $eta =sqrt{B^2+J^2}$, and $beta =frac{1}{T}$. Both $J, B$ are reals.

I used

Z = 2 (Cosh(2 β J) + Cosh(2 β η));
η = Sqrt(B^2 + J^2);
β = 1/T;
Eig = (8 (η + η Cosh(2 β η) Cosh(2 β J) + 
    J Sinh(2 β η) Sinh(2 β J)))/(Z^2 η)
Limit(Eig, T -> 0)

But I can’t understand the output.

unit testing – How do I really write tests without mocking/stubbing?

I have been using TDD when developing some of my side projects and have been loving it.

The issue, however, is that stubbing classes for unit tests are a pain and makes you afraid of refactoring.

I started researching and I see that there are a group of people that advocates for TDD without mocking–the classicists, if I am not mistaken.

However, how would I go about writing unit tests for a piece of code that uses one or more dependencies? For instance, if I am testing a UserService class that needs UserRepository (talks to the database) and UserValidator (validates the user), then the only way would be… to stub them?

Otherwise, if I use a real UserRepository and UserValidator, wouldn’t that be an integration test and also defeat the purpose of testing only the behavior of UserService?

Should I be writing only integration tests when there is dependency, and unit tests for pieces of code without any dependency?

And if so, how would I test the behavior of UserService? (“If UserRepository returns null, then UserService should return false”, etc.)

Thank you.

integration testing – Hypothetically if every scenario were covered by an end-to-end tests, would unit tests still have any value?

Note: I’m asking about the strategy behind unit / integration / end-to-end tests, not about classifying tests as one or the other.

More so in the past than present, it was expensive to write and run end-to-end tests for every possible scenario. Now though, for example with the increased use of test fixtures / emulators, or even lower latency / higher query limits to APIs, it’s more feasible. But of course there’s always gonna be human error. We can never be sure we thought of every scenario.

Still I’m asking anyway, hypothetically, given an oracle that tells us every possible scenario, or to put it another way, discounting scenarios other than exactly the ones with end-to-end tests, how might unit tests still be valuable?

What I’m wondering is if, unit-integration tests are kind of an “alternate approach” to thinking about tests, and that’s the advantage of writing them even when aiming for “100%” end-to-end coverage: because they might catch a scenario missed by human error. But eliminate human error in thinking up scenarios, and what do they do?

Some ideas I can come up with (but I’m hoping for even stronger answers!)

  • They encourage a useful coding methodology, e.g. TDD.
  • On a breaking dependency (or dependent API) change, they reveal precisely where.

reference request – Is realization of unit disk graphs hard?

It is known that recognizing a unit disk graph is NP-hard (1).

However, the paper does not mention how hard is the realization problem.

I have looked up several references (2)(3)(4). None of the papers answer whether the following problem is NP-hard:

Given a unit disk graph $G = (V,E)$, find a configuration of a set
$mathcal{D}$ of disks, such that the intersection graph
$G(mathcal{D})$ of $mathcal{D}$ is isomorphic to $G$.

The difference between this problem and the recognition problem is that the input of this problem is guaranteed to be a unit disk.

Is there any study that shows the complexity of the above problem? I expect it to be NP-hard, but I am yet to find a full proof.

phpunit – PHP unit con laravel voyager

Estoy creando un Featuretest para un proyecto desarrollado en laravel y utilizando el paquete voyager.
Acá el codigo de mi test

Cuando ejecuto el test, me da un error, que hace referencia a la ruta, (que en este caso es: “voyager.marcas.store” ), indicando que no esta definida.
(imagen de error o código)

voyager tiene su propio archivo de rutas que está en vendor.
Entonces, agregué un metodo seTup, para indicar la ruta base de la ruta voyager, pero ahora me muestra que no encuentra la ruta.

Alguien con mas experiencia con voyager que me pueda ayudar.
les agradezco desde ya.