Flashdevelop / HaxePunk: Build halted with errors - haxe

I've been trying to follow this tutorial to get started with HaxePunk. I am using FlashDevelop and have got to trying to run the program after adding the logo.png. However, when I run the program I get the following output:
Running process: C:\Program Files (x86)\FlashDevelop\Tools\fdbuild\fdbuild.exe "D:\Haxe Projects\Prj_Starting\Prj_Starting.hxproj" -ipc f201d2c5-2ffe-46d4-bb54-c67a3e34ab4a -version "3.2.1" -compiler "C:\Program Files\HaxeToolkit\haxe" -library "C:\Program Files (x86)\FlashDevelop\Library" -target "neko"
Building Prj_Starting
Running Pre-Build Command Line...
cmd: "C:\Program Files\HaxeToolkit\haxe/haxelib" run lime build "project.xml" neko -debug -Dfdb
[file_contents,C:\Program Files\HaxeToolkit\haxe\lib\lime//.current]
Build halted with errors.
Done(1)
No error specific error is given so I am unsure what is wrong. I have followed the tutorial exactly and these are my classes:
Main.hx
import com.haxepunk.Engine;
import com.haxepunk.HXP;
class Main extends Engine
{
override public function init()
{
#if debug
HXP.console.enable();
#end
HXP.scene = new MainScene();
}
public static function main() { new Main(); }
}
MainScene.hx
import com.haxepunk.Scene;
class MainScene extends Scene
{
public override function begin()
{
add(new Logo());
}
}
Logo.hx
package src;
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.utils.Input;
import com.haxepunk.utils.Key;
/**
* Logo entity.
* #author Abigail Smith
*/
class Logo extends Entity
{
private var speed:Int;
public function new()
{
super(270, 190);
speed = 5;
graphic = new Image("graphics/logo.png");
}
public override function update():Void {
if (Input.check(Key.RIGHT)) {
moveBy(speed, 0);
}
if (Input.check(Key.LEFT)) {
moveBy(-speed, 0);
}
if (Input.check(Key.DOWN)) {
moveBy(0, speed);
}
if (Input.check(Key.UP)) {
moveBy(0, -speed);
}
}
}
Any help with this solving this error would be appreciated. Thank you :)

It looks like you have a problem with one of the library you need that called "lime".
[file_contents,C:\Program Files\HaxeToolkit\haxe\lib\lime//.current]
Open cmd and type haxelib list
Check if you can see lime library there
If it's there then run haxelib update lime else you need to install it by running haxelib install lime
Hope this solves your problem!

Related

groovy is not finding annotated tests

Still new to Groovy and trying to figure out unit testing. I'm trying to use the Junit4 style of testing.
import org.junit.Test
import junit.framework.*
import junit.textui.TestRunner
class DegenerateTestCase {
#Test
void testAlwaysTrue() {
assert true
}
#Test
void someMethodName() {
assert true
}
}
TestRunner.run(DegenerateTestCase)
But when I run the script, I get
There was 1 failure:
warning(junit.framework.TestSuite$1)junit.framework.AssertionFailedError:> No tests found in DegenerateTestCase
This has to be something simple that I'm missing.
I am using Eclipse Java EE IDE for Web Developers, Oxygen.3a Release (4.7.3a). I have the Groovy plugin downloaded from the marketplace (compiler level 2.5).
I tried running it with junit5 which had only one difference which was instead of having import org.junit.Test I had import static org.junit.jupiter.api.Assertions.*. I didnt need import junit.framework.* or import junit.textui.TestRunner I just ran it as is and worked fine.
I then switched to Junit4 and did the same but switched import static org.junit.jupiter.api.Assertions.* to import org.junit.Test and it works.
my code looks like this:
import org.junit.Test
class DegenerateTestCase {
#Test
void testAlwaysTrue() {
assert true
}
#Test
void someMethodName() {
assert true
}
}

Use Gmail API in a keyword in Katalon Studio

I use this tutorial to connect to Gmail API: https://developers.google.com/gmail/api/quickstart/java
I would like to make a keyword in Katalon Studio, which depends on Gmail API.
I modified from sample code that line:
InputStream in = GmailQuickstart.class.getResourceAsStream(CREDENTIALS_FILE_PATH);
to this:
InputStream ins = new FileInputStream(CREDENTIALS_FILE_PATH);
JAR files are added, project is running and browser window is opened to get token. After successful authorization I got error message:
Caused by: java.lang.NoSuchMethodError:
com.google.api.client.http.HttpRequest.setResponseReturnRawInputStream(Z)Lcom/google/api/client/http/HttpRequest;
UPDATE: List of imported dependencies:
commons-codec-1.15.jar
commons-logging-1.2.jar
google-api-client-1.31.3.jar
google-api-client-extensions-1.6.0-beta.jar
google-api-client-jackson2-1.31.3.jar
google-api-client-java6-1.31.3.jar
google-api-services-gmail-v1-rev110-1.25.0.jar
google-http-client-1.39.1.jar
google-http-client-jackson2-1.39.1.jar
google-oauth-client-java6-1.31.4.jar
google-oauth-client-jetty-1.31.4.jar
guava-30.1.1-jre.jar
httpclient-4.5.13.jar
httpcore-4.4.14.jar
j2objc-annotations-1.3.jar
jackson-core-2.12.2.jar
jsr305-3.0.2.jar
https://docs.katalon.com/katalon-studio/docs/external-libraries.html#exclude-built-in-libraries
With the ability to remove built-in libraries stored in the .classpath file of a project folder, you can replace a built-in library with an external one for flexible libraries usage in a test project.
Requirements
An active Katalon Studio Enterprise license.
Katalon Studio version 7.8.
UPD:
i got katalon 7.9.1 and here how i was able to do it:
add the following class into KS project:
include/scripts/groovy/(default package)/GroovyBox.java
import groovy.lang.*;
import java.util.regex.Pattern;
import java.util.Map;
import java.util.List;
/** run groovy script in isolated classloader*/
public class GroovyBox {
GroovyShell gs;
public GroovyBox(ClassLoader parentCL, Pattern excludeClassPattern ) {
FilteredCL fcl = new FilteredCL(parentCL, excludeClassPattern);
gs = new GroovyShell(fcl);
}
public GroovyBox withClassPath(List<String> classPathList) {
GroovyClassLoader cl = gs.getClassLoader();
for(String cp: classPathList) cl.addClasspath(cp);
return this;
}
public Script parse(String scriptText) {
return gs.parse(scriptText);
}
public static class FilteredCL extends GroovyClassLoader{
Pattern filterOut;
public FilteredCL(ClassLoader parent,Pattern excludeClassPattern){
super(parent);
filterOut = excludeClassPattern;
}
#Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException{
if(filterOut.matcher(name).matches())throw new ClassNotFoundException("class not found "+ name);
return super.loadClass(name, resolve);
}
}
}
now add a test case - actually you can move code from test case into a class...
import ... /* all katalon imports here*/
assert method1() == 'HELLO WORLD'
def method1() {
def gb = new GroovyBox(this.getClass().getClassLoader().getParent(), ~/^com\.google\..*/)
def script = gb.parse('''
#Grab(group='com.google.api-client', module='google-api-client', version='1.31.3')
import com.google.api.client.http.HttpRequest
def c = HttpRequest.class
println( "methods execute:: "+c.methods.findAll{it.name=='execute'} )
println( "methods setResponseReturnRawInputStream:: "+c.methods.findAll{it.name=='setResponseReturnRawInputStream'} )
println greeting
return greeting.toUpperCase()
''')
script.setBinding([greeting:'hello world'] as Binding)
return script.run()
}
options to define external dependencies:
#Grab(...) as a first line of parsed script - loads all required dependencies from maven central (by default). for example #Grab(group='com.google.api-client', module='google-api-client', version='1.31.3') corresponds to this artifact.
sometimes you need to specify specific maven repository then add #GrabResolver(name='central', root='https://repo1.maven.org/maven2/')
if you want to specify local file dependencies then in the code above:
def gb = new GroovyBox(...).withClassPath([
'/path/to/lib1.jar',
'/path/to/lib2.jar'
])

Node.js, access typescript static variable from different files

I have a situation like this in a node.js project:
test.ts
export class Test {
private static test: string = 'hallo';
public static initialize() {
Test.test = 'changed';
}
public static showTest() {
console.log(Test.test);
}
}
At the begin I initalize Test..
app.ts
import { Test } from './test.ts'
...
Test.initialize();
Test.showTest(); // shows --> 'changed'
then I call a function of a class stored in another file
otherFile.ts
import { Test } from './test.ts'
...
someFunction() {
Test.showTest(); // shows --> 'hallo'
}
Is there a way to make the showTest() function show 'changed' also on the second call without reinitializing Test?
Thank you!
Davide
in this situation i prefer use localStorage
because every time we import class , that reintilized

How can I make Selenium tests inside my JSF project?

I have quite big JSF 1.2 project and I want to write some integration tests to it.
The perfect situation will be, when I can run these tests from my project and it opens my browser and makes all the actions (with Selenium), which are written in my test cases. Ofc opening browser is not required when It will run these tests anyway :)
I've tried a few possibilities, anyway I still can't attach any selenium library to my project and I realized that I just dont know where to start - can you give me some direction?
might help you ,
you can write you test logic inside test method
package com.test;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.fail;
public class test1 {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
#Before
public void setUp() throws Exception {
driver = new InternetExplorerDriver();
driver = new ChromeDriver();
baseUrl = "http://www.google.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
#Ignore
#Test
public void test1() throws Exception {
// your test code
}
#After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}
you just need call test1 class which you want to test it .
it will be automatically working on it .

Unit tests - run task programmatically

I'm creating custom task for gradle. I don't know how I can create task which will use my custom task class. Is it possible? I want to create this task for functional tests which will be runned on jenkins.
This is my custom task:
package pl.gradle
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
class MyCustomTask extends DefaultTask {
public MyCustomTask() {
// do something
}
#TaskAction
def build() {
ant.echo(message: "only for tests")
}
}
And this is my test class:
package pl.gradle
import static org.junit.Assert.*
import org.gradle.testfixtures.ProjectBuilder
import org.gradle.api.Project
import org.junit.Before;
import org.junit.Test
class MyCustomTaskTest {
private Project project;
def task
#Before
public void setUp() {
project = ProjectBuilder.builder().build()
task = project.task("build", type: MyCustomTask)
}
#Test
public void taskCreatedProperly() {
assertTrue(task instanceof MyCustomTask)
}
#Test
public void shouldRunTask() {
// task.execute() // how to run this task? I want to run build() method from MyCustomTask class which is #TaskAction
}
}
ProjectBuilder is meant for lower-level tests that don't execute tasks. Its sweet spot is testing plugins. In addition you'd write higher-level tests that execute real builds (and therefore also tasks). You'd typically use the Gradle tooling API to kick off these builds. Check out the tooling API samples in the full Gradle distribution.
Call Action.execute yourself for each of the task actions:
project.tasks.getByName("myTask").with { Task task ->
assertEquals task.group, 'My Group'
task.actions.each { Action action ->
action.execute task
}
}
I've previously mentioned this here: https://stackoverflow.com/a/63613564/410939

Resources