Search Feedback

1
votes

Unit tests should not fail when an error is logged

Scripting

-

-

Unity unit tests fail when an error is logged to the console.

Why would that ever be a good idea? We find it quite annoying. We want our tests to fail when the assertions we wrote are not fulfilled. We don't want our tests to fail when some code we don't control (or code we're not testing right now) decides to log an error message. A log message should just be a log message, nothing more.

This behaviour should be removed completely, or at least configurable. The only way to get rid of this behaviour is to actually expect an error log, with the same exact text. This makes no sense from a unit testing point of view. If we are testing function A, why should we know the exact error message logged by a distant function Z? We should only care about the possible results of function A.

Please make tests not fail when error messages are logged!

Thanks.

Comments (2)

  1. 7ce31bbe40eae7bbc5af71e88e52e29e?d=mm

    rmassanet

    Feb 15, 2018 07:40

    As I said in my post: "The only way to get rid of this behaviour is to actually expect an error log, with the same exact text. This makes no sense from a unit testing point of view."

  2. 6d9bee86efe06f84e79934221afc95ab?d=mm

    Garth-Smith

    Feb 15, 2018 00:45

    You can tell a unit test to expect a Debug.LogError to occur. We use this to make sure we display an error for a unit test that purposely causes an error.
    https://docs.unity3d.com/Manual/testing-editortestsrunner.html

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(9911)

2D

(260)

Ads

(50)

AI & Navigation

(77)

Analytics

(115)

Animation

(366)

Asset Store

(271)

Assets

(510)

Audio

(169)

Cloud Build

(122)

Collaborate

(45)

Docs & Tutorials

(217)

Editor

(2293)

Everyplay

(13)

Game Performance Reporting

(16)

General

(890)

Graphics

(821)

GUI

(397)

Input

(157)

Licensing

(84)

Networking

(176)

Physics

(362)

Platforms

(427)

Profiling & Optimization

(76)

Runtime

(171)

Scripting

(1097)

Terrain

(164)

WebGL

(138)