Laravel 4 No tests found in TestCase - phpunit

I'm having some problems with phpunit. When I execute a test, phpunit give me these warnings:
1) Warning
No tests found in class "Illuminate\Foundation\Testing\TestCase".
2) Warning
No tests found in class "TestCase".
But I'd like to ignore these files, so that phpunit won't try to run tests from them.
How to do that?

Hopefully by now you found the answer but if you haven't this might help:
Hmm - make sure that the filenames and class names all match up. For
example, no FooTest class with a filename of BarTest.php.
Also, are you positive that you have a *Test.php file within the
app/tests directory?
[...]
That was it, i.e. one of my tests had a typo in the filename-vs-classname. Odd that typo kicks a warning in the TestCase classes and instead of flagging the class that actually caused it.
From:
https://laracasts.com/forum/?p=83-warnings-for-testcase-illuminate-foundation-testing-testcase/0
Basically, make sure your file names and class names match up. I was banging my head on this one too.

An additional solution could be to make the TestCase class abstract. By doing so, PHPUnit will not try to find any tests in it.
abstract class TestCase {

For me, the problem was that the class name did not match the file name, so a class defined as
class ExampleTest {
was not named ExampleTest.php.
If there are certain test files you would want to ignore, then go into the phpunit.xml file and inside
<testsuite name="Application Test Suite">
<directory></directory>
</testsuite>
replace the directory tags with tags and specify the specific test file you want to use.

For me, I had a convention mistake. The solution was changing the class name, and file, from TestFoo to FooTest.

I was also facing the same problem. I've checked that my file name and class name were the same as AuthTest.php and AuthTest respectively.
But still I was getting the same warning maybe because I've renamed the ExampleTest.php to AuthTest.php.
Anyways I've deleted the previous file and used the php artisan make:test AuthTest
and it worked.

Related

Snakemake: wildcards do not expand in script line of rule

I am running a pipeline and was trying to optimize it by declaring the paths in a config file (config.yaml). The config.yaml file contains the path to find the scripts to run inside the pipeline, but when I expand the wildcard of the path, the pipeline does not run the script. The script itself runs fine.
To explain my problem:
rule with_script:
input: someinput
output: someoutput
script: expand("{script_path}/scriptfile", script_path = config[scriptpath])
input, output or rule all do not contain the script's path wildcard, so here is the first time I'm declaring it. The config.yaml line that contains the path looks like this:
scriptpath: /path/to/the/script
is there a way to maintain the wildcard and config file path (to make it easier for others to make changes if needed) and have the script work? Like this snakemake doesn't even enter the script file. Or maybe it is possible to declare global wildcards outside the rule all?
Thank you for your help!
P.S.: I'm sorry if this question has already been answered, but I couldn't find anything to help me with this.
You cannot define a function like expand() in the script section. Snakemake expects a path to your script.
Like the documentation states:
The script path is always relative to the Snakefile containing the directive (in contrast to the input and output file paths, which are relative to the working directory). It is recommended to put all scripts into a subfolder "scripts"
If you need to define different paths to your scripts, you can always do it in python outside of your rules. Don't forget, all python code outside of rules is executed before building the DAG. Thus, you can define all variables you want and use them in your rules.
SCRIPTSPATH = config["scriptpath"]
rule with_script:
input: someinput
output: someoutput
script: "{SCRIPTSPATH}/scriptfile"
Note:
Do not mix wildcards and "variables". In an expand function as
expand("{script_path}/scriptfile", script_path = config[scriptpath])
{script_path} is not a wildcard but just a placeholder for the values given in the second parameter of the function.

CMake COMPILE_DEFINITIONS triggering incorrect number of arguments

I'm having problem understanding how to correctly set the COMPILE_DEFINITIONS target properti in CMake.
my target is add_library(modelutilities STATIC ${modelutilities_SRCS})
I if use
set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
set_target_properties(modelutilities PROPERTIES
VERSION "0.0.1"
SOVERSION 0
EXPORT_NAME "ModelUtilities"
ARCHIVE_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/bin"
COMPILE_DEFINITIONS ${modelutilities_COMPILE_DEFINE}
)
everything works fine, but if I add another line between them with set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} MODELUTILITIES_LIB) it stops working complaining that set_target_properties was called with the wrong number of arguments.
Anyone can spot what I'm doing wrong?
P.S.
I already tried using doublequotes: set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} "MODELUTILITIES_LIB"). It did not change anything
P.P.S.
If I message(STATUS ${modelutilities_COMPILE_DEFINE}) QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB in the first case and QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;MODELUTILITIES_LIB in the second
With newer version of CMake, what is being preached is the idea of targets. So, for example, instead of include_directories() it's now preferred to use target_include_directories().
That being the case I think you'd be better served using the preferred target_compile_definitions() to set compile definitions for your utilities library.
One advantage you get is that your can scope your compile definitions using the PUBLIC or PRIVATE keywords.

Multiple classes in a single file leads to overload warnings

I've recently started playing around with the closure compiler and ES6, and I've noticed something that I think is a bit strange. When I compile the following code:
export class Test
{
constructor(arg)
{
this.arg = arg;
}
}
class Test2
{
constructor(diffArg)
{
this.diffArg = diffArg;
}
}
I get this output when I compile with ADVANCED:
java -jar closure-compiler-v20170910.jar --compilation_level ADVANCED --language_in ECMASCRIPT6_TYPED --language_out ECMASCRIPT5 --js_output_file ui.js --js javascript/*.js --externs javascript/externs/externs.js --jscomp_off missingProperties
Test.js:11: WARNING - Function and method overloads are not supported and type information might be lost
constructor(diffArg)
^^^^^^^^^^^^^^^^^^^^^^
Test.js:5: ERROR - variable arg is undeclared
this.arg = arg;
^^^
It looks like the compiler is complaining because there are two functions with the same name in the file - even though they are in different classes - and the error comes in because the second function replaces the first. If I compile with SIMPLE, I get the warning but not the error, and the emitted code seems to contain the second constructor definition. To get the code to compile properly, I need to put each class into its own file.
My question is whether this is expected behavior or not - I don't believe that there is anything in the ES6 spec about only having one class per file, and since each function is in a different class, I would have expected that I can use the same name for each of them (especially for the constructor). Is there a way to get around this, or is having each class in its own file the right way to go?

Qt - moc causing C2504: base class undefined

I'm having a problem that I've been trying to solve for a while, but I am completely stumped. So I have two classes, X and Y, and they each have their own header files, X.h and Y.h. Each is a Q_OBJECT and has that macro definition in the header file.
class Y: public X { Q_OBJECT ...}
The definition of Y reads. The definition of X reads:
class X: public QGLWidget {Q_OBJECT ...}
When I compile, X.cpp and Y.cpp compile correctly and there are no problems at that stage. The moc files are also generated with no problem.
However, when the standard QT build process goes to compile moc_X.cpp, it gives me "C:\path\Y.h(34) : error C2504: 'X' : base class undefined". But this doesn't happen when it's compiling Y.cpp or X.cpp, it only happens when it's compiling the moc files! Any ideas? That the build would be failing at the moc stage and only moc stage seems extremely peculiar. Help is much appreciated!
I've tried reproducing it, with the description you give, and haven't been able to.
So, here are things that would be worth checking:
errors in include guards?
Check that you haven't accidentally got 2 include-guards of the same name in 2 different headers (i.e. the #ifndef X_H and #define X_H lines)
(This is perhaps less likely, from your description: it would be more likely if the error was in the compiling of moc_Y.cpp)
forward declarations for types used in signals or slots?
Sometimes a parameter in a signal or slot can require an extra header to be included.
The best way I can explain it is to say that there are cases where your header would be fine with a forward-declaration to a class, but the moc can generate code that needs to actually create or destroy a type that your header only forward-declares.
If this is the case, there is a way to add code to the .ui, that requests inclusion of the extra header for the forward-declared type. But the easiest solution is just to replace the forward declaration with the appropriate header instead, inside X.h or Y.h.
check the contents of the moc_X.cpp file
If the above doesn't help, and if you haven't done so already, I'd suggest opening up the offending moc file and reading the code. Once you see what it's doing, it might give you some ideas.

Qt moc error 1 - what does it mean?

I'm trying to build a project on Mac OSX, and it's giving me a cryptic error:
[moc_droparea.cpp] Error 1
droparea.cpp is (obviously) a file in the project. I checked that it exists in the project directory and is not corrupted. The file moc_droparea.cpp doesn't show up in the build folder after this error, so I'm assuming it's failing to build for whatever reason, but the error is too vague to help me figure out what's going on. Could anyone help me figure out what this means please?
Click on "compile output", scroll up and click the red line.
In my case the Red line was saying: You cant define an integer value in private slots..
Under the qt creator window, in "progress details" section, there is a button named "compile output" (button number 4). Errors are explained there with red font. Click it and scroll up.
The solution was annoyingly simple. I had a folder structure that put spaces (illegal characters) in the file path. I put underscores instead of spaces and it built fine. I would think the moc pre-processor could handle spaces in file names, but apparently not. I feel foolish, but at least the problem is solved now.
Hopefully this solution can help someone else.
This can be because of few other things as others have mentioned. I would like to add another one which is missing here.
You will get a "moc error 1" in case you create a class and add Q_OBJECT to it but do not inherit from QObject.
If you take a look at Compile Output there is a line saying:
Error: Class contains Q_OBJECT macro but does not inherit from QObject
Hence, the general approach to fix this problem is just taking a look at "Compile Output" window.
This can be because of many things I guess - I had a similar situation where I forgot to remove an entry in the .qrc file that didn't exist anymore.
So check your resource paths as well.
You can right click on the error 1 and select 'View output'. In my case, I had a bad file name in my qrc file.
Like J.Javan already pointed to, it might be helpful to check also the compiler output. In my case I found:
../stateMaschine/usermenu.h:57: Error: Class declarations lacks
Q_OBJECT macro. make: *** [Makefile:215: moc_usermenu.cpp] Error 1
So this helped me to fix the error by correction of the class declaration when using signals and slots:
class Menu : public QObject{
Q_OBJECT
...
Same Error 1 occured to me due to a ressource file (.qrc) which referred to a file name beginning with a period. When I removed the period from the file name, compilation worked again. Interestingly, the error only occured under Mac OSX using the Clang compiler. On Windows using the gcc compiler, the file name did not provoke an error.
Maybe the "[source file name] Error 1" message in general means that a file could not be found due to unexpected characters in the file path.
In my case, I ran out of space on SD card causing this sort of error.

Resources